EEPROM TO PWM

eeprom to pwm

The code can be downloaded at :

https://github.com/triantara/ARDUINO-TRIANTARA/blob/main/EEpromPWM.zip

#include <avr/interrupt.h>
#include <avr/eeprom.h>
int addr = 1;
int readValue;
int a;
int b;
int encoder_pin = 5;
void setup()
{
Serial.begin(9600);
pinMode(encoder_pin, INPUT);
}

void loop() {
if (Serial.available() > 0) {
a = Serial.parseFloat();
while (!eeprom_is_ready());
cli();
if(eeprom_read_word((uint16_t*)addr) != a) {
eeprom_write_word((uint16_t*)addr, a);
}
sei();

}
else{
readValue = eeprom_read_word((uint16_t*)addr);
b=readValue*10;
Serial.print(“Serial Input = “);
Serial.print(readValue);
Serial.print(” “);
Serial.println(b);
readValue = constrain(readValue, 0, 255);
analogWrite(encoder_pin, readValue);
}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s