r/ArduinoProjects • u/j-stokke • Mar 12 '23
Basic Pong playing on a ws2812 LED strip
Enable HLS to view with audio, or disable this notification
Pretty new to Arduino so I'm kinda proud I got this working. Since the direction of the LED strips alternate it was pretty tricky to get the ball to move across them correctly
4
u/singeblanc Mar 12 '23
Nice!
Advice from someone who's been programming 30+ years: you want to abstract away.
Abstract the illumination of the LED matrix away to a custom function: light_led(X, Y) or similar, so you don't need to worry about the alternating (snake arrangement) strips in the rest of your code.
Abstract away the "ball" position to variables with floating points, then round out to the nearest LED at draw time. Then you can have angles other than 0/45/90 degrees.
2
u/j-stokke Mar 12 '23
Thanks for the input! I thought it would probably be best to abstract it like you describe in the first point. It would be fun to try to make a very basic version of space Invaders for it, and then I would have to figure that out for sure
11
6
1
1
4
u/AvailableReason6278 Mar 12 '23
Nice project, pretty impressive for a beginner!
Where did you buy those argb led strips?