0

Rock Paper Scissor Begginer

I'm trying to code this minigame but it seems that the pushbuttons doesn't gives out signal that it's being push what is the problem in my code?

#include <LiquidCrystal.h>
const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 = 9, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int a = 0;
int b = 0;

#define rock 7
#define paper 6
#define scissor 5
#define rock2 4
#define paper2 3
#define scissor2 2

int rockState = 0;
int paperState =0;
int scissorState =0;
int rock2State =0;
int paper2State =0;
int scissor2State =0;


void setup(){
lcd.begin(16,2);

pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(scissor2, INPUT);
pinMode(paper2, INPUT);
pinMode(rock2, INPUT);
pinMode(scissor, INPUT);
pinMode(paper, INPUT);
pinMode(rock, INPUT);

digitalWrite(0, LOW);
digitalWrite(1, LOW);
lcd.clear();
lcd.setCursor(6,0);
lcd.print("START");
}
void loop(){
rockState = digitalRead(7);
paperState = digitalRead(6);
scissorState = digitalRead(5);
rock2State = digitalRead(4);
paper2State = digitalRead(3);
scissor2State = digitalRead(2);


if (rockState == HIGH && rock2State == HIGH){ //tie
lcd.clear();
lcd.print("TIE");
delay(1000);
}
else if (paperState == HIGH && paper2State == HIGH){ //tie
lcd.clear();
lcd.print("TIE");
delay(1000);
}
else if (scissorState ==HIGH && scissor2State == HIGH){ //tie
lcd.clear();
lcd.print("TIE");
delay(1000);
}
else if (rockState == HIGH && scissor2State == HIGH || paperState == HIGH && rock2State == HIGH || scissorState == HIGH && paper2State == HIGH){ // Player 1 Wins
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
lcd.clear();
lcd.print("Player 1 Wins");
delay(600);
lcd.setCursor(0,1);
lcd.print(a+1);
delay(1000);

}
else if (rockState == HIGH && paper2State == HIGH || paperState == HIGH && scissor2State == HIGH || scissorState == HIGH && rock2State == HIGH){ // Player 2 Wins
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
lcd.clear();
lcd.print("Player 2 Wins");
delay(600);
lcd.setCursor(0,1);
lcd.print(b+1);
delay(1000);

}

}

0 comments

Please sign in to leave a comment.