they are wired 5v to pin, and pin to ground with 10k resistor.
Working here means that the buttons read, and count, and cannont be pressed at the same time. as designed.
what is not working is the lights on pins 11, 12;
redPin and greenPin. they are always on.
i have had people check my circit for shorts etc. but we have found nothing. so i moved here after i couldnt (besideds convention/ comonalities) find anything opperationaly wrong(not as designed) with my code.
changeing to the && now.
and yes it would be better to use else. ill change that.
done
void loop(){
//
greenState = digitalRead(greenButton);
redState = digitalRead(redButton);
if(redState == HIGH && greenState == LOW)
{
redTeam(); // run redTeam
}
if(greenState == HIGH && redState == LOW)
{
greenTeam(); // run greenTeam
}
if(pointValue <= redCount || pointValue <= greenCount)
{
win();
}
}
//000000000000000000000000000000000000000
void redTeam(){
redState = digitalRead(redButton);
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, LOW);
if(redState == HIGH)
{
redCount++;
delay(500);
if(redCount < greenCount)
{
digitalWrite(whitePin, HIGH);
}
else
{
digitalWrite(whitePin, LOW);
}
}
}
void greenTeam(){
greenState = digitalRead(greenButton);
digitalWrite(greenPin, HIGH);
digitalWrite(redPin, LOW);
if(greenState == HIGH)
{
greenCount++;
delay(500);
if(greenCount < redCount)
{
digitalWrite(whitePin, HIGH);
}
else
{
digitalWrite(whitePin, LOW);
}
}
}
got some || or's in there as well