How do I add eeprom on my arduino code?
int potPin = 0; // analog input pin 0 for the potentiometer
int motor1Pin = 7; // H-bridge leg 1
int motor2Pin = 6; // H-bridge leg 2
int val = 0; // variable to store the value coming from the potentiometer
void setup()
{
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
}
void loop()
{
val = analogRead(potPin); // read the value from the potentiometer
val = val/4; // convert 0-1023 range to 0-255 range
if (val <= 85)
{
digitalWrite(motor1Pin, HIGH); // set leg 1 of the H-bridge low
delay(100);
digitalWrite(motor2Pin, LOW); // set leg 2 of the H-bridge high
}
else if (val >=86 && val<=170)
{
digitalWrite(motor1Pin, LOW); // set leg 1 of the H-bridge low
delay(100);
digitalWrite(motor2Pin, LOW); // set leg 2 of the H-bridge high
}
else
{
digitalWrite(motor1Pin, LOW); // set leg 1 of the H-bridge high
delay(100);
digitalWrite(motor2Pin, HIGH); // set leg 2 of the H-bridge low
}
}