New answers tagged

1

I cannot see, how your code would show the described behavior (assuming that, you have connected the buttons correctly with a pulldown resistor). But your code can be greatly simplified, which would make it less error prone. You have 8 buttons, which screams for the usage of arrays (IMO you should always use arrays, if you have more than 2 or 3 equal ...


0

So based on the information you provided I understand that the issue is that both the if(switch1state==HIGH) and the `if(switch2state==HIGH)' statements evaluate to true if either switch is flipped. That means one of the following things is happening: 1) Somewhere in your code you're mixing their values and assigning ones value to the other 2) Your ...


2

It turns out the problem was the A2 pin on the board. When I used the A0 pin (or a different board) the problem goes away. I realised something was wrong when I noticed the values from the pot were strange (I expected values in the range 0 - 1023, but was receiving values from 170-250 ish).


1

The String+ operator is very expensive. High likely what it does is: Create a new block of memory to accommodate the old string content and the to-be-concatenated text. Copy the current String to a new string location Concatenate the string Free the old memory Besides creating memory gaps which can be disastrous for the just 2 KB SRAM of the Arduino Uno, ...


Top 50 recent answers are included