Fingertron-3000
Built a Python-Arduino Setup That Counts My Fingers and Flashes the Number on a Display. Totally Unnecessary, But Ridiculously Fun!
Supplies
System Requirements
- Python 3.11 (recommended version) - (conservative releases)
- Arduino Uno
- Webcam or external camera
Python to Arduino Communication
I wanted to figure out how to send commands from Python to Arduino. Here’s a basic Python code snippet for sending a specific number to an Arduino via serial communication
I attempted to create a loop to test the wiring connections. Something like this:
number = 0 # Define Number
while number <= 9:
if 0 <= number <= 9:
arduino.write(str(number).encode())
print(f"Sent number {number} to Arduino")
time.sleep(1)
else:
print("Invalid number.(1..9)")
number += 1
Downloads
Camera and Hand Detection With Mediapipe
To count the fingers on an open hand, I used Mediapipe. Here’s a Python code snippet to open the camera and count fingers:
Explanation:
- mp.solutions.hands: Detects hand landmarks.
- count_fingers: Determines finger count by comparing landmark positions.
- cv2.putText: Displays the finger count on the video feed.
Downloads
Combining the Two
Then combined them and make communication with the finger detection and Arduino:
Downloads
Check Out the Complete Project
Check out the complete project on my GitHub account: @gafelson