For the project, I was walking around my room and looking for creative ways to create a switch. Finally, I found two American pennies which are made from zinc and are coated with copper, both of which are good conductive materials. Then, I realized I could make a switch that works when the coins touch. Wires are taped to the coins so that when the coins touch, the circuit closes and lights up the yellow LED. I connected the green and blue wires together to extend the reach of the coins. The idea is similar to Carrom – the coin that has an extended reach has to be flung into the other coin which will be relatively stationary. The setup can be seen below.
Next, I write some code for the Arduino, so that when they touch, the LED stays lit for 3 seconds so that the contact is captured and a hit or miss can be seen clearly.
void setup() { // put your setup code here, to run once: pinMode(9, OUTPUT); pinMode(A5, INPUT); } void loop() { // put your main code here, to run repeatedly: int switchState = digitalRead(A5); if (switchState == HIGH){ digitalWrite(9, HIGH); delay(3000); } else{ digitalWrite(9, LOW); } }