Possible bug: inconsistent results when transpiring code with constants in "main"

Consider the following segment of a patch I’m working on:

The analog input is connected to a momentary pushbutton with a pull-up resistor to the supply, that pulls the analog pin down to ground when the button is engaged. Digital output connected to LED pin 13 on the Arduino Redboard.

Set constants T1 and T2 both to 0.5, click “Deploy” and “Show code for Arduino.” Copy and paste transpiled code into Arduino IDE v 1.8.3. The program starts up with the LED OFF and when I push the button the analog input pin is connected to ground, boolean output of “less” goes HIGH and the LED turns on as expected while holding the button, off when the button is released.

I delete output node “OUT2” and leave the output from “greater” unconnected, as if someone has made an error…:sweat_smile: Follow the same steps to transpile code and upload via the Arduino IDE. The Arduino locks up. Then go back and undo the deletion so everything is exactly as it was before. Repeat the process again…and the Arduino still locks up. But go back into “main”, alter the values of the constants there somewhat from what they were and transpile and upload again, and for me the patch is working again as before. Doesn’t seem to matter which constant is altered, even the one not relevant to the functioning of the single digital output in this instance.

Here’s a link to a zip with the project as I have it set up:


Didn’t checked for myself yet but looking at the steps you’ve described I wonder…

What patch do you upload? Isn’t it hysteresisinput instead of the main at this stage? Now I understand the mechanics could be very misleading, but currently, the opened patch gets transpiled and uploaded. So it could happen you’re uploading the wrong patch. And it looks like Arduino hangs although it works but has no way to show it to you.

Can this be the problem?

OK, that could very well be the problem. I’d been experimenting with the code-generation output because I’d like to deploy my project on an ATTiny, but I guess I didn’t realize that worked on a per-patch basis, not a per project basis.

I just looked more closely and noticed that the node count does differ depending on what tab I have open when I select that option. I would’ve noticed it if I’d scrolled down - wasn’t on my screen. Feeling pretty dumb at the moment…:sweat_smile:

I’ll get back once I’m sure that so long as I always ensure that I choose the transpile function when I have the “main” tab in focus it resolves the issue