Hello people,
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
VID: 2341
PID: 0243
SN: 755333538373513071F0
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;
void setup()
{
pinMode(ledgreen, OUTPUT);
pinMode(ledred0, OUTPUT);
pinMode(ledred1, OUTPUT);
pinMode(button, INPUT);
}
void loop()
{
buttonstate = digitalRead(button);
if (buttonstate == LOW)
{
digitalWrite(ledred0, HIGH);
digitalWrite(ledred1, HIGH);
digitalWrite(ledgreen, LOW);
}
else
{
digitalWrite(ledred0, HIGH);
digitalWrite(ledred1, LOW);
digitalWrite(ledgreen, LOW);
delay(125);
digitalWrite(ledred0, LOW);
digitalWrite(ledred1, HIGH);
delay(125);
}
}

