Vous êtes sur la page 1sur 10

Quiz Show controller

Primary tabs

View(active tab)

What links here

published by MRE on Fri, 11/02/2012 - 23:16

Here is a shot of the insides of my quiz show box.

Lots of space in there! The arduino is bolted to the metal base plate. The shield is only there to
provide a strong attachment point for the wires. Unfortunately, I only had solid core bell wire, so
the cabling is quite stiff and hard to work with. Next time I'll use ribbon cable!
Burried under the wires are two SIP resistor packs. The LED pack is 2K ohms. I would have
liked 500 ohms. They would be much brighter then. But I didnt have any in my inventory, and
did not want to solder individual resistors. Common pin on the SIP goes to ground. Digital
outputs on the Arduino send current through the LED, then through the SIP resistor pack.
The Buttons are mounted in seperate boxes. They are typical arcade style. I was fortunate to find
a local shop with 6 colors. Each button has a long cable (at least 5 meters) so that I can use this
kit in a school classroom. The player groups could be pretty far from the main box.
Buttons are tied high with another SIP resistor pack. In this case, the common pin on the SIP is
connected to 5 volts. The resistor output is then tied to the analog inputs (I am using them as
digital inputs). Also tied to the input is one leg of the switch (via the RCA connector on the box).
The other end of the switch is connected to ground. When the switch is open, current flows into
the input, registering a HIGH value in software. When the switch is closed, current takes the path
of least resistance, going stright to ground, rather than entering the Arduino input pin. The
software reads this as a LOW condition.
I have space in the box for future upgrades. I plan on installing a "correct" and "incorrect" button
on the head unit, as well as a reset (so I can bypass the 5 second timer).
In addition to winner determination, the software also provides a serial message output. I hope to
eventually connect it to a PC and write some gameshow software.

Below you will find the Arduino code:

/*

Quiz Show buttons


Emery Premeaux
<a href="http://www.DIY-SciB.org

">http://www.DIY-SciB.org
</a> This simple quiz show kit supports 6 buttons and LEDs.
Buttons should be pulled high by resistors, and tied to A0-A6.
LEDs are attached via resistors to digital pins 2 through 7.
Default condition, all LEDs are light (It helps to know power is on ;)
When a button is pressed, Three things happen:
1: All LEDs are extinguished, and the winning LED is relit.
2: A message is sent out the serial port. Use it to communicate with a PC
game if you like.
3: A 5 second timer locks out all other buttons. After the timer
completes, the LEDs are reset and buttons
are ready for input again.
*/
// Let's assign names
#define P1LED 2
#define P2LED 3
#define P3LED 4
#define P4LED 5
#define P5LED 6
#define P6LED 7
#define
#define
#define
#define
#define
#define

P1SW
P2SW
P3SW
P4SW
P5SW
P6SW

A0
A1
A2
A3
A4
A5

int P1, P2, P3, P4, P5, P6;


int WinDelay = 5000;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(P1LED, OUTPUT);
pinMode(P2LED, OUTPUT);
pinMode(P3LED, OUTPUT);
pinMode(P4LED, OUTPUT);
pinMode(P5LED, OUTPUT);
pinMode(P6LED, OUTPUT);
pinMode(P1SW, INPUT);
pinMode(P2SW, INPUT);

pinMode(P3SW,
pinMode(P4SW,
pinMode(P5SW,
pinMode(P6SW,

INPUT);
INPUT);
INPUT);
INPUT);

Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
LEDsOn();
P1 = digitalRead(P1SW);
if(P1==0){
Win(1);
}
P2 = digitalRead(P2SW);
if(P2==0){
Win(2);
}
P3 = digitalRead(P3SW);
if(P3==0){
Win(3);
}
P4 = digitalRead(P4SW);
if(P4==0){
Win(4);
}
P5 = digitalRead(P5SW);
if(P5==0){
Win(5);
}
P6 = digitalRead(P6SW);
if(P6==0){
Win(6);
}
}
void Win(int Winner){
switch (Winner){
case 1:
LEDsOff();
digitalWrite(P1LED, HIGH);
Serial.println("Player 1");
delay(WinDelay);
LEDsOn();
break;
case 2:
LEDsOff();
digitalWrite(P2LED, HIGH);
Serial.println("Player 2");
delay(WinDelay);
LEDsOn();
break;
case 3:
LEDsOff();
digitalWrite(P3LED, HIGH);
Serial.println("Player 3");

delay(WinDelay);
LEDsOn();
break;
case 4:
LEDsOff();
digitalWrite(P4LED, HIGH);
Serial.println("Player 4");
delay(WinDelay);
LEDsOn();
break;
case 5:
LEDsOff();
digitalWrite(P5LED, HIGH);
Serial.println("Player 5");
delay(WinDelay);
LEDsOn();
break;
case 6:
LEDsOff();
digitalWrite(P6LED, HIGH);
Serial.println("Player 6");
delay(WinDelay);
LEDsOn();
break;
}

void LEDsOn (){


digitalWrite(P1LED,
digitalWrite(P2LED,
digitalWrite(P3LED,
digitalWrite(P4LED,
digitalWrite(P5LED,
digitalWrite(P6LED,
}

HIGH);
HIGH);
HIGH);
HIGH);
HIGH);
HIGH);

void LEDsOff (){


digitalWrite(P1LED,
digitalWrite(P2LED,
digitalWrite(P3LED,
digitalWrite(P4LED,
digitalWrite(P5LED,
digitalWrite(P6LED,
}

LOW);
LOW);
LOW);
LOW);
LOW);
LOW);

- See more at: http://diy-scib.org/blog/quiz-show-controller#sthash.BhGfa1bz.dpuf

Materials:

Arduino Duemilanove (or Uno)

1 2-digit 7-segment display (I got a 50-piece LED display grab bag for better
value (plus the fun factor!) the one I used was configured as shown)

2 Mini push button switches

9 Resistors, 100 Ohm

2 Resistors, 10K Ohm

2 2N3906 transistors (PNP)

1 Solderless breadboard

Jumper Wires in assorted lengths

//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//

www.TinkerHobby.com
Natalia Fargasch Norman
Dual seven-segment LED Display
Common Anode digit 1 pin 10
Common Anode digit 2 pin 5
CA1 G
| |
--------|
A
|
F|
|B
|---G---|
E|
|C
|
D
|
--------| |
D DP

F
|

A B
| |
-> pins and segments they control
--------|
A
|
F|
|B
|---G---|
E|
|C
|
D
|
--------| | |
-> pins and segments they control
E C CA2

Segments that make each number when lit:


0 => -FEDCBA
1 => ----BC2 => G-ED-BA
3 => G--DCBA
4 => GF--CB-

//
//
//
//
//

5
6
7
8
9

=>
=>
=>
=>
=>

GF-DC-A
GFEDC-A
----CBA
GFEDCBA
GF-DCBA

// Arduino digital pins used to light up


// corresponding segments on the LED display
#define A 3
#define B 2
#define C 6
#define D 8
#define E 7
#define F 4
#define G 5
// Pins driving common anodes
#define CA1 13
#define CA2 12
// Pins for A B C D E F G, in sequence
const int segs[7] = { A, B, C, D, E, F, G };
// Segments that make each number
const byte numbers[10] = { 0b1000000, 0b1111001, 0b0100100, 0b0110000,
0b0011001, 0b0010010,
0b0000010, 0b1111000, 0b0000000, 0b0010000 };
void setup() {
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
pinMode(E, OUTPUT);
pinMode(F, OUTPUT);
pinMode(G, OUTPUT);
pinMode(CA1, OUTPUT);
pinMode(CA2, OUTPUT);
}
void loop() {
for (int digit1=0; digit1 < 10; digit1++) {
for (int digit2=0; digit2 < 10; digit2++) {
unsigned long startTime = millis();
for (unsigned long elapsed=0; elapsed < 600; elapsed = millis() startTime) {
lightDigit1(numbers[digit1]);
delay(5);
lightDigit2(numbers[digit2]);
delay(5);
}
}
}
}
void lightDigit1(byte number) {
digitalWrite(CA1, LOW);

digitalWrite(CA2, HIGH);
lightSegments(number);
}
void lightDigit2(byte number) {
digitalWrite(CA1, HIGH);
digitalWrite(CA2, LOW);
lightSegments(number);
}
void lightSegments(byte number) {
for (int i = 0; i < 7; i++) {
int bit = bitRead(number, i);
digitalWrite(segs[i], bit);
}
}

Vous aimerez peut-être aussi