Fastest FInger First Using Arduino (Max 6 Players)

1,652

3

2

Hi there my name is Aditya and this is a follow up to my previous instructable check it out here -:

https://www.instructables.com/id/Fastest-Finger-Fi...

In my previous instructable i said i will publish a new one with max players if it gets up to 50 views, So here is it

Parts needed are-:

1. Arduino Uno (you can use any other arduino board the code may differ)

2. L.E.Ds 6x

3. Momentary pushbuttons 6x

4. Resistors 1k ohm 6x

5. Jumper Wires

The code is at the bottom or somewhere

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Simple As That

Upload the code to your respected Arduino board and connect all the wires where they need to be connected

See the image for connections

Step 2: How It Works

I explained how the code works check the previous instructable

https://www.instructables.com/id/Fastest-Finger-Fi...

I just declared more pins and wrote new if statements check out the code to see how i did that

If you have any questions ask them in the comment section -_-

I know there can be more players by using the arduino mega but you should have understood how to write the code

2 Discussions

int ledpin1 = 2; // here we declare all the output led pins and all the input analog pins
int ledpin2 = 3;
int ledpin3 = 4;
int ledpin4 = 5;
//int ledpin5 = 6;
//int ledpin6 = 7;
int analogpin1 = A0;
int analogpin2 = A1;
int analogpin3 = A2;
int analogpin4 = A3;
//int analogpin5 = A4;
//int analogpin6 = A5;
int threshold = 1021; // here is the threshold value
void setup() {
// put your setup code here, to run once:
pinMode(ledpin1, OUTPUT); // here we set all the output pins to output and all the input pins to input mode
pinMode(ledpin2, OUTPUT);
pinMode(ledpin3, OUTPUT);
pinMode(ledpin4, OUTPUT);
//pinMode(ledpin5, OUTPUT);
//pinMode(ledpin6, OUTPUT);
pinMode(analogpin1, INPUT);
pinMode(analogpin2, INPUT);
pinMode(analogpin3, INPUT);
pinMode(analogpin4, INPUT);
//pinMode(analogpin5, INPUT);
//pinMode(analogpin6, INPUT);
}
void loop() {
int L1,L2,L3,L4;
L1= L2=L3=L4=0;
// put your main code here, to run repeatedly:
int analogvalue1 = analogRead(analogpin1);
int analogvalue2 = analogRead(analogpin2);
int analogvalue3 = analogRead(analogpin3);
int analogvalue4 = analogRead(analogpin4);
if(analogvalue1 > threshold){
L1=1;
L2=L3=L4=0;
}
if(analogvalue2 > threshold){
L2=1;
L1=L3=L4=0;
}
if(analogvalue3 > threshold){
L3=1;
L1=L2=L4=0;
}
if(analogvalue4 > threshold){
L4=1;
L1=L2=L3=0;
}
while(L1==1 || L2==1 ||L3==1 || L4==1)
{
if(L1==1){
digitalWrite(ledpin1, HIGH);
digitalWrite(ledpin2, LOW);
digitalWrite(ledpin3, LOW);
digitalWrite(ledpin4, LOW);
}
if(L2==1){
digitalWrite(ledpin2, HIGH);
digitalWrite(ledpin1, LOW);
digitalWrite(ledpin3, LOW);
digitalWrite(ledpin4, LOW);
}
if(L3==1){
digitalWrite(ledpin3, HIGH);
digitalWrite(ledpin1, LOW);
digitalWrite(ledpin2, LOW);
digitalWrite(ledpin4, LOW);
}
if(L4==1){
digitalWrite(ledpin4, HIGH);
digitalWrite(ledpin1, LOW);
digitalWrite(ledpin2, LOW);
digitalWrite(ledpin3, LOW);
}
}
}

i have done some modification....