Pages: [1]   Go Down
Author Topic: Jeopardy! Game Board Code Issues  (Read 852 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
//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);
}

}
Logged

Knivsta,Sweden
Offline Offline
Sr. Member
****
Karma: 0
Posts: 274
Low level's cool
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26278
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: July 09, 2010, 03:29:06 pm by AWOL » Logged

"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.

Pages: [1]   Go Up
Jump to: