OttoDIY / blockly

Otto Blockly; a fully integrated graphical programming for any type of Arduino projects, including robots, ready to install in your computer, it works offline and also online
https://www.ottodiy.com/software
GNU General Public License v2.0
115 stars 81 forks source link

Starting the serial monitor resets the value of variables #117

Closed brendonhatcher closed 2 years ago

brendonhatcher commented 3 years ago

I created the attached code. I downloaded it to Otto. Tapping on the sensor shows the number "1" and repeat tapping increments the number by 1 each time. I then open the Serial Monitor and press "Start". When I tap again, the number displayed is "1". I continue to tap, and the number increments. I then close the Serial Monitor and tap again. The number has reset to 1 again

serial monitor reset issue Otto_block_tap to count.zip

cparrapa commented 3 years ago

Hi @brendonhatcher

I think is because the serial monitor resets the board therefore start form the beginning again every time you close, I do not recall if in Arduino IDE it is the same situation actually

brendonhatcher commented 3 years ago

I found this post that confirms that the issue is the same for the Arduino IDE. It appears that the board resets as a result of the configuration of the Windows (in my case) software providing the serial communication between the Nano and OttoBlockly. This is either a simple code change in OttoBlockly, or something too complex but insignificant to try to fix.

https://forum.arduino.cc/t/serial-connect-resets-board/25409

cparrapa commented 3 years ago

Make sense is far beyond the actual Arduino IDE, we can add a warning when explaining the concept of serial monitor. A way to store the variable will be to use the EEPROM memory