I’m playing with the SIK, with the help of the guide I’m slowly learning, I’m working on a script that will light up the LED of the button you press unless you press yellow and blue simultaneously, in which case the Green LED will light-up, for now I’m just working on getting the buttons to work with the LEDS, as I have it now the script looks like this
const int GnBttn=2; //Declares "GnBttn" as a Constant and Sets Value
const int RdBttn=3; //Declares "RdBttn" as a Constant and Sets Value
const int BlueBttn=4; //Declares "BlueBttn" as a Constant and Sets Value
const int YlwBttn=5; //Declares "YlwBttn" as a Constant and Sets Value
//5
const int GnLED=8; //Declares "GnLED" as a Constant and Sets Value
const int RdLED=9; //Declares "RdLED" as a Constant and Sets Value
const int BlueLED=10; //Declares "BlueLED" as a Constant and Sets Value
const int YlwLED=11; //Declares "YlwLED" as a Constant and Sets Value
//10
void setup()
{//12
int Bttns[] = {YlwBttn, GnBttn, RdBttn, BlueBttn}; // Declares "Bttns" as an index and sets the values equal to the Bttn Variables
int LEDs[] = {YlwLED, GnLED, RdLED, BlueLED}; // Declares "LEDs" as an index and sets the values equal to the LED Variables
int index; // declares "index" as a variable
for (index = 0; index <= 4; index++)//Creates For loop, sets "index" to 0 at beginning, runs when "index" is less then or equal to 4, adds one to "index" each time it runs
{//17
pinMode (Bttns[index], INPUT); //Sets Pin# "Bttns[index]" as an Input
pinMode (LEDs[index], OUTPUT); //Sets Pin# "LEDs[index]" as an Output
digitalWrite (LEDs[index], HIGH); //turns on "LEDs[index]"
delay(100);//waits 100 Milliseconds
}//22
delay(100);// Waits 100 Milliseconds
for (index = 0; index <= 4; index++)//Creates For loop, sets "index" to 0 at beginning, runs when "index" is less then or equal to 4, adds one to "index" each time it runs
{//25
digitalWrite (LEDs[index], LOW);//turns off "LEDs[index]"
}//26
}//30
//31
void loop()
{//33
int YlwBttnState; //Declares "YlwBttnState" as a variable
int RdBttnState; //Declares "RdBttnState" as a variable
int GnBttnState; //Declares "Gn BttnState" as a variable
int BlueBttnState; //Declares "BlueBttnState" as a variable
//38
YlwBttnState=digitalRead(YlwBttn); //Sets Value of "YlwBttnState" to value read from pin "YlwBttn"
GnBttnState=digitalRead(GnBttn); //Sets Value of "GnBttnState" to value read from pin "GnBttn"
RdBttnState=digitalRead(RdBttn); //Sets Value of "RdBttnState" to value read from pin "RdBttn"
BlueBttnState=digitalRead(BlueBttn); //Sets Value of "BlueBttnState" to value read from pin "BlueBttn"
//43
//44
//When a Button is Pushed it will be read as LOW
if (RdBttnState==LOW) //if Value of "RdBttnState" is off
{//47
digitalWrite (RdLED, HIGH); //Send Power to pin "RdLED"
}//49
else//50
{//51
digitalWrite (RdLED, LOW); //Turn off pin "RdLED"
}//53
//54
if (GnBttnState==LOW) //if Value of "GnBttnState" is off
{//56
digitalWrite (GnLED, HIGH); //Send Power to pin "GnLED"
}//58
else//59
{//60
digitalWrite (GnLED, LOW); //Turn off pin "GnLED"
}//62
//63
if (YlwBttnState==LOW) //if Value of "YlwBttnState" is off
{//64
digitalWrite (YlwLED, HIGH); //Send Power to pin "YlwLED"
}//66
else//67
{//68
digitalWrite (YlwLED, LOW); //Turn off pin "YlwLED"
}//70
//71
if (BlueBttnState==LOW) //if Value of "BlueBttnState" is off
{//73
digitalWrite (BlueLED, HIGH); //Send Power to pin "BlueLED"
}//75
else//76
{//77
digitalWrite (BlueLED, LOW); //Turn off pin "BlueLED"
}//79
}//80
and the circuitry looks like this:http://i1026.photobucket.com/albums/y32 … dligin.png
When I push the red or yellow buttons it works as expected, but the blue LED is always on, regardless of the state of the blue Button, and the yellow LED is always off, regardless of the state of the yellow button.
I’m farly certain it is a code problem because when I switch out components it has no effect on how the Circuit works.
Any help is much appriciated.