-->
Page 1 of 1

attiny85 + esp8266 + button = :(

PostPosted: Fri Dec 19, 2014 10:34 am
by juanmol
Hi, i'm trying to get work an attiny85 with an esp8266 wifi module, to control a led. I can do it, but i need to integrate a button to do the same that the esp8266, but manually. I have this code:
Code: Select allvoid loop()
{
  //change the led status with a button START
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH && lastButtonState == LOW) {
    delay(50);
    if (ledState == 0) {   
      digitalWrite(led, HIGH);
      ledState = 1;
    }
    else {
      digitalWrite(led, LOW);
      ledState = 0;
    }
  }
  lastButtonState = buttonState;
  //change the led status with a button END
 
  //change led status with a wifi received order START
  if (finder.find("led1off")  ){
    digitalWrite(led, LOW);
    ledState = 0;
  }
  if (finder.find("led1on")  ){
    digitalWrite(led, HIGH);
    ledState = 1;
  }
  //change led status with a wifi received order end
}


the wifi received part, works perfect, but the button doesn't. If i put only the button code, it works, but it doesn't work if i put it all together. Sometimes turn on/off and sometime makes esp8266 reset. Please help.