Hey soooo I’m trying to make an interactive pong game with arduino. Basically, I am using an infrared emitter and receiver to detect when an object is over them, and moving your hand will move the pong paddle left or right. I am using a TLC5940 with 16 leds. What I need to figure out how to code is how to make the " pong ball " roll down the leds toward the paddle WHILE the Infrared receiver is constantly reading for data. So here is the code to make the " ball " move towards the paddle
Tlc.clear();
Tlc.set(14,3000);
delay(300);
Tlc.update();
Tlc.set(14,0);
Tlc.set(11,3000);
delay(300);
Tlc.update();
Tlc.set(11,0);
Tlc.set(8,3000);
delay(300);
Tlc.update();
Tlc.set(8,0);
Tlc.set(5,3000);
delay(300);
Tlc.update();
Tlc.set(5,0);
Tlc.set(2,3000);
delay(300);
Tlc.update();
Tlc.set(2,0);
delay(300);
Tlc.update();
and While this is going on, I need to have analogRead(A5) constantly taking in data, but I am unsure of how to do this. So… after a measured amount of time, if your hand is over the correct " paddle - IR Receiver" , the ball will go back to where it came from and come back towards the paddle. Here is the code for the IR Receiver …
int Receiver = analogRead(A5);
if (Receiver < (Threshold - 7))
..... make the ball go back
else
start level over or whatever.
These things work perfectly independently, but how can I make them run at the same time??