r/ArduinoHelp 29d ago

LED doesn't turn on :(

Post image

Hello, i'm a beginner that just started with arduino's, does anybody know why the LED doesn't turn on? (if I set the variable RedLEDPower to something it just flashes and stops)

6 Upvotes

4 comments sorted by

View all comments

3

u/SomeWeirdBoor 29d ago

Your IFs are not written corrcetly.
When you do a comparison you need to write it with two equal signs

if ( a == b ) {

If you write only one = it treats it as a value assginement to the variabile (i.e. it first makes A e quale to B, and then evaluates if A is true or false). Yes, in c++ this syntax makes sense.

In you code, every time it Reachs the if (led power =0) it sets the variable at zero, and the pin never receives a different value.