In these days of the Corona crisis simple games can help to keep your kids (and yourself) occupied. Therefore I build one. I guess everybode knows this game. There is a track made of wire and there is a loop wich must maneuvered along the track without touching it.
Here is the basic idea. This is a picture from Wikipedia
You can build this with a few electronic parts. You can even build this with just a led and a battery. And you can build it with a ESP8266. Using the latter you can ad leds, 7 segment displays etc. to fancy it up.
I build this with an ESP8266. It can easily be altered for using an Arduino or one of its family members. By exchanging the leds for neopixels and altering the program accordingly you could even use an Attiny85 to make this project.
Breadboard.
The setup is simple. 3 leds are attached to D7, D6 and D5. A button is attached to D0. The track wire is connected to GND and the loop wire is connected to D1. If you do have a Piezo Buzzer attach it to D2.
The program
Nothing special in the program. Each time the wires touch a led is lit, and the buzzer sounds. If you touch the wire more as three times your done and nothing further happens till you push the button and the game is reset for the next attempt or contestant.
const int BuzzerPin = 4;
const int ContactPin = 5;
const int ButtonPin = 16;
const int ledpin1 = 13;
const int ledpin2 = 12;
const int ledpin3 = 14;
int count;
void setup()
{
pinMode(ContactPin,INPUT_PULLUP);
analogWrite(BuzzerPin, 0);
pinMode(ledpin1, OUTPUT);
pinMode(ledpin2, OUTPUT);
pinMode(ledpin3, OUTPUT);
digitalWrite(ledpin1, LOW);
digitalWrite(ledpin2, LOW);
digitalWrite(ledpin3, LOW);
count = 0;
}
void loop()
{
if(digitalRead(ContactPin)==0)
{
analogWrite(BuzzerPin, 200);
delay(400);
analogWrite(BuzzerPin, 0);
if (count <3)
{
count ++;
}
}
switch (count)
{
case 1:
digitalWrite(ledpin1, HIGH);
break;
case 2:
digitalWrite(ledpin2, HIGH);
break;
case 3:
digitalWrite(ledpin3, HIGH);
break;
}
if ((digitalRead(ButtonPin)== LOW) && (count == 3))
{
digitalWrite(ledpin1, LOW);
digitalWrite(ledpin2, LOW);
digitalWrite(ledpin3, LOW);
count = 0;
analogWrite(BuzzerPin, 0);
delay (1000);
}
}
If you do not own a buzzer you can easily leave that part out. The program can easily be modified to use a display instead of leds etc.
In real life.
I just used a solid electrical wire for the track and a piece of the same wire for the loop.
Above is my prototype on a breadboard. The track is a wire across the breadboard. The loop is on the left side at the bottom. A coathanger is the best material for the loop and track. Put it on a wooden shelf for sturdiness and experiment with different shapes.
Have fun
Luc Volders