This project connects a Unity car game with Arduino Uno to display speed on a 3-digit 7-segment display and control a fan motor.
Final report available at: Documentation/final-report.md
Final presentation slides available at: Documentation/presentation.pdf
- Refer to Miro Board: https://miro.com/app/board/uXjVJs10bzI=/
- Unity: Simple car game with steering wheel input
- Arduino Uno: 7-segment display (5641AS) and motor control
- Display: 5641AS 4-digit 7-segment display (common cathode) - using 3 digits
- Motor: 5V fan motor
Segment Pins (connect all 8 segments):
- Segment pins connected to: 9, 2, 3, 5, 6, 8, 7, 4
- Pin 9 → Segment a
- Pin 2 → Segment b
- Pin 3 → Segment c
- Pin 5 → Segment d
- Pin 6 → Segment e
- Pin 8 → Segment f
- Pin 7 → Segment g
- Pin 4 → Segment dp (decimal point)
Digit Pins (only connect first 3 digits):
- Digit 1 (leftmost) → Pin 10
- Digit 2 (middle) → Pin 11
- Digit 3 (rightmost) → Pin 12
- Digit 4 → Not connected (pin 13 is used for motor)
- Motor positive to digital pin 13 (PWM)
- Motor negative to GND via transistor for proper current handling
- Install SevSeg library in Arduino IDE (Sketch > Include Library > Manage Libraries > Search for "SevSeg")
- Upload
ArduinoCode/simdash.inoto Arduino Uno for Unity integration- Or upload
ArduinoCode/simdash_test/simdash_test.inofor standalone testing without Unity
- Or upload
- Note the COM port (e.g., COM3 on Windows, /dev/ttyACM0 on Linux)
- Open the project in Unity (2020+ recommended)
- In
SerialCommunicator.cs, updateportNameto match your Arduino port (e.g., "COM3" for Windows or "/dev/ttyACM0" for Linux) - Open the
Assets/Scenes/CarDrivingScene.unityscene - The scene includes:
- Car: A cube with CarController and Rigidbody components
- Ground: A large plane for driving
- Main Camera: Positioned above and behind for a good view
- Directional Light: Provides scene lighting
- GameManager: Contains SerialCommunicator for Arduino connection
- Upload
simdash.inoand note the port - Open Unity project
- Run the scene
- Use steering wheel to control car
- Speed will be sent to Arduino, updating display and fan
- Upload
simdash_test.ino - Open Serial Monitor (9600 baud)
- Watch the display count from 0-100 and back
- Feel the motor speed up and slow down automatically
- 3-digit display shows speed 0-100
- Motor PWM is mapped from speed (0-100 → 0-255 PWM)
- Pin 13 used for motor control (4th digit not connected)
- Display uses SevSeg library with common cathode configuration
- Ensure serial port permissions on Linux/Mac (
sudo usermod -a -G dialout $USER)
