attiny85 + esp8266 + button = :(
Posted: Fri Dec 19, 2014 10:34 am
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:
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.
Code: Select all
void 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.