Hey, people, i need help.
I have an lcd, and I am using it in a reaction timer project. What it is SUPPOSED to do is this: The led is off for a random amount of time. When it tuns on, the two players race to press their button as fast as they can. If a foul occurs, then a low tone is played and the lcd shows who fouled. If it is not a foul, the LCD shows who won and what their time was.
Here is the code
/* Reaction Timer
By- Racerdude24
This is a game where there is an led and two buttons. as soon as the led lights up, the first player to push the button wins. If pushed before that, it is a foul. If won, the lcd shows who
along with the winner's time. If foul, it shows who.
*/
// wiring:
// ----------------^ means on lcd, ~ means on arduino--------------------
/* *Ground & 5v to pins 1^ & 2^, respectively
*2K pot, 2 ends to 5v & Ground, wiper to pin 3^
*Digital pin 7~ connected to pin 4^
*Pin 5^ connected to ground
*Pin 6^ connected to digital pin 8~
*Pin 11^ connected to digital pin 9~
*Pin 12^ connected to digital pin 10~
*Pin 13^ connected to digital pin 11~
*Pin 14^ connected to digital pin 12~
*Pin 6~ to 5v by pushbutton Switch
*Pin 6~ to ground by resistor
*Pin 5~ to 5v by pushbutton switch
*Pin 5~ to ground by resistor
*Pin 13~ to ground by LED
*Speaker connected to Pin 4~ & Ground
******************************************** These next two pins will only be on an lcd with a backlight. If there is no backlight, ignore these next 2 steps.
*Pin 15^ connected to 5v via 220 ? resistor
*Pin 16^ connected to ground
``````````To adjust contrast, twist the 2K potentiometer```````````
*/
#include "pitches.h"
#include <LiquidCrystal.h>;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
const int led = 2; //the pins used.
const int player1 = 6;
const int player2 = 5;
const int speaker = 4;
int pressed = 0;
int ready = 0;
int currentmillis = 0;
int time = 0;
void setup(){
Serial.begin(9600);
lcd.begin (16, 2);
randomSeed(analogRead(0));
time = random(1000, 6000);
}
void loop(){
currentmillis = millis();
if (currentmillis > time){ //if the delay is over
ready = 1; //make any following presses non-foul
digitalWrite(led, HIGH); //turn the led on
}
if (digitalRead(player1) == HIGH){ //if player 1 pushed his button
if (pressed == 0){ //was something pressed already? if not...
if (ready == 1){ //is it a foul? if not...
pressed = 1; //keep the other player from pressing
lcd.print("Player 1 wins!!"); //self explanatory
lcd.setCursor(0, 1);
lcd.print((float)(currentmillis - time)/1000);//print the reaction time
tone(4, NOTE_C4, 1000); //play a high tone
}
else{ //if it is a foul
lcd.print("Foul on player 1"); //also self explanatory
pressed = 1; //keep other player from pressing
tone(4, NOTE_C3, 1000); //play low tone
}
}
else{
}
}
if (digitalRead(player2) == HIGH){ //this code is the same as player 1's, with a few changes
if (pressed == 0){
if (ready == 1){
pressed = 1;
lcd.print("Player 2 wins!!");
lcd.setCursor(0, 1);
lcd.print((float)(currentmillis - time)/1000);
tone(4, NOTE_C4, 1000);
}
else{
lcd.print("Foul on player 2");
pressed = 1;
tone(4, NOTE_C3, 1000);
}
}
}
}
However, if you look at the video, you see that the LCD is not showing any characters. I don't think it is the code, because it worked before. Am I applying too much voltage to it? The Pic shows that I am using 3.3v, but beforehand I was using 5v. Could that have damaged it?
I have no idea what the product number is, I just know it is made by samsung.
Some things it says on the back are:
*FCT 3135
*UC-16202-GNAR5-V97051503
*Samsung (logo)
*0052A
Here is a videohttp://www.youtube.com/watch?v=NIQn7qGfgJ8
And lastly, A photo. (on attatchment)
All I need to know: Is it broken? and Can it be fixed?