ESP8266 - micropython global variable does not work
Posted: Sun May 20, 2018 9:07 am
Hi there,
A few days ago I have flashed my ESP board and set up micropython. The first thing I have setup is temperature/humidity monitoring and led strip control over mqtt protocol. The problem for me was that I did not know whether am I leave led strip turned on or off, so I added flag(boolean) in order to track the led strip status. So, this sounded as a good solution for me,but I have found the problem, I have declared isLedOn variable as False at the beginning of the main.py file. Every time when I turn on or off led strip this variable gets updated with he appropriate value, but in main loop I am reading value False all the time, even though I have updated it with True value.
Please fin my code on pastebin and please take a look at it and see if I made any mistake during the coding.
https://pastebin.com/jmwqThJf
can somebody tell me where is the problem
thanks
A few days ago I have flashed my ESP board and set up micropython. The first thing I have setup is temperature/humidity monitoring and led strip control over mqtt protocol. The problem for me was that I did not know whether am I leave led strip turned on or off, so I added flag(boolean) in order to track the led strip status. So, this sounded as a good solution for me,but I have found the problem, I have declared isLedOn variable as False at the beginning of the main.py file. Every time when I turn on or off led strip this variable gets updated with he appropriate value, but in main loop I am reading value False all the time, even though I have updated it with True value.
Please fin my code on pastebin and please take a look at it and see if I made any mistake during the coding.
https://pastebin.com/jmwqThJf
can somebody tell me where is the problem
thanks