Go Down

Topic: unable to use EEPROM functions of ATtiny13A (Read 814 times) previous topic - next topic

this is the code i uploaded to my ATtiny13A using my Arduino UNO as an ISP Programmer...
the program is like if i cut my IR sensor for 7 times .. then only my led switches on..
i want it in such a way that even if the power for the ic is cut off the ic should start from the point where it
stopped ...so i am storing the number of times i cut the sensor in EEPROM of the ic...
but the EEPROM part of the code is not working..
i need a bit of help here on how to write and read the EEPROM of ATtiny13A...??
please...

#include<EEPROM.h>
int ir=1;
int led=4;
int a=0;
boolean b=LOW;
void setup()
{
  pinMode(led,OUTPUT);
  pinMode(button,INPUT);
  a=EEPROM.read(0);
  if(a==7)
  {
    a=0;
   }
}
void loop()
{
  if(digitalRead(button)==HIGH&&b==LOW&&a<7)
  {
    a++;
    EEPROM.write(0,a);
    b=HIGH;
  }
  if(digitalRead(button)==LOW&&b==HIGH)
  {
    b=LOW;
  }
  if(a==7)
  {
    digitalWrite(led,HIGH);
  }
}

Erni

If you are using smeezekitty's core  you can take a look at this:

http://forum.arduino.cc/index.php?topic=89781.150


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy