I have no other experience of programming, but I excited with the capabilities of the Arduino UNO, so I decided to buy one. More specifically I bought a Genuino Starter Kit from Arduino.cc, and I started straight away with the projects book’s first and second project.
In the second project (spaceship interface), after I did all the whirring, and had written the code I noticed that something is going wrong. According to the code as you know when I type “digitalWrite(3, HIGH);”, the led that is connected to pin 3 should be ON, and when I type “digitalWrite(3, LOW);”, the led that is connected to pin 3 should be OFF, but the exact opposite is happening.
The board information is:
BN: Arduino/Genuino Uno
And I use Arduino 1.8.2 to compile the code on Windows 10 PC.
Is there any way to fix this or any other potential issues?
Thankyou in advance.
This is the code:
const int ledred0 = 5;
const int ledred1 = 4;
const int ledgreen = 3;
const int button = 2;
int buttonstate = 0;
buttonstate = digitalRead(button);
if (buttonstate == LOW)