Go Down

Topic: Jeopardy! Game Board Code Issues (Read 984 times) previous topic - next topic

aaronjames806

Hello Forum, this is my first Arduino project not from a book and I am running into some trouble. My goal is to make an led system like a simplified version of the one on the game Jeopardy in which when a force sensor is pushed, its corresponding led lights up and then after 4 seconds the red led lights up indicating that time has run out. When one sensor is pushed, it shouldn't let the other led come on. The problem is in the time between when the sensor is pressed and when its led turns on. It seems to take a while to light up, or it won't light up at all.
Here's the code and thanks!



Code: [Select]
//Building a Jeopardy! Buzzer System with LEDs
//If one sensor is pressed its LED lights up and blocks the other
//After 4 seconds the red LED turns on

int sensorAPin = 1;
int sensorBPin = 2;
int ledAPin = 10;
int ledBPin = 9;
int ledCPin = 11;
int val=0;
int val2=0;

void setup(){
 pinMode (ledAPin, OUTPUT); //LED is an OUTPUT
 pinMode (ledBPin, OUTPUT); //LED is an OUTPUT
 pinMode (ledCPin, OUTPUT); //LED is an OUTPUT
}

void loop(){
 val = analogRead (sensorAPin);
 val2 = analogRead (sensorBPin);
 
if (val>500 && val2<500){
   digitalWrite (ledAPin,HIGH);
   digitalWrite (ledBPin,LOW);
   delay(4000);
   digitalWrite (ledCPin, HIGH);
}

else if (val<500 && val2>500){
 digitalWrite (ledAPin,LOW);
 digitalWrite (ledBPin,HIGH);
 delay(4000);
 digitalWrite (ledCPin, HIGH);
}

}

drhex

Have you verified that 500 is the proper cutoff-value for your buttons?

aaronjames806

I have tried it with a variety of different numbers but i figured that it would give me a result between 0-1023 so 500 was a safe number. Also i tried it with 1 instead of 500 and then the light goes on by itself. Might I have faulty touch sensors?

AWOL

#3
Jul 09, 2010, 10:28 pm Last Edit: Jul 09, 2010, 10:29 pm by AWOL Reason: 1
Quote
Might I have faulty touch sensors?


Possibly, but you don't say what they are or how they are wired.
I'm guessing floating inputs.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up