I helped develop the code for GROUP 1 of PHISLCA FAB BSAET 3-2 SY 25-26 This project demonstrates the construction of a 360-degree scanning sonar system using a 28BYJ-48 stepper motor for precise rotation and an HC-SR04 ultrasonic sensor for distance detection.
An Arduino Uno coordinates both components—rotating the motor incrementally and measuring distance at each step. The Arduino transmits these readings as angle,distance pairs via a serial connection to a host computer.
A Processing 4 visualization script receives this data and renders a live radar-style interface, complete with a fading green sweep and red echo indicators that represent detected objects.
- Arduino Uno (or compatible board)
- 28BYJ-48 Stepper Motor with ULN2003 Driver Board
- HC-SR04 Ultrasonic Sensor
- Jumper wires (male-male, male-female)
- Mount or holder to attach the ultrasonic sensor to the motor (3D print, cardboard, or glue)
-
Arduino IDE (v1.8.x or v2.x)
-
Processing 4
-
Project files:
stepper_radar_final.ino– Arduino codestepper_radar_visualization.pde– Processing sketch
Connect all components to the Arduino as follows:
Ultrasonic Sensor (HC-SR04)
| HC-SR04 Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| TRIG | A0 |
| ECHO | A1 |
Stepper Motor Driver (ULN2003)
| ULN2003 Pin | Arduino Pin |
|---|---|
| IN1 | 8 |
| IN2 | 9 |
| IN3 | 10 |
| IN4 | 11 |
| Power | 5V |
| Ground | GND |
💡 Mount the HC-SR04 securely on the stepper shaft so it rotates with the motor.
- Connect your Arduino Uno via USB.
- Open
stepper_radar_final.inoin the Arduino IDE. - Select Tools → Board → Arduino Uno.
- Select the correct Tools → Port for your device.
- Click the Upload button (arrow icon).
- Wait for the “Done uploading” message.
- Close the Serial Monitor — only one program can access the serial port.
-
Open
stepper_radar_visualization.pdein Processing 4. -
Click Run
▶️ . -
Check the Processing console — it will list all available COM ports (e.g.,
[0] COM1,[1] COM5,[2] COM7). -
Identify which COM port your Arduino uses and note its index number.
-
Stop the sketch ⏹️.
-
Find and edit this line in the code:
String portName = Serial.list()[0]; // Change index if needed
Example: If your Arduino is on COM5 and appears as
[1], modify it to:String portName = Serial.list()[1];
- Ensure the Arduino is connected and powered.
- Run the Processing sketch again.
- A radar window will appear showing a rotating sweep with live distance readings visualized in real time.
Possible Causes & Fixes:
- The wrong COM port was selected — verify and update the index.
- The Arduino Serial Monitor is still open — close it and restart Processing.
- The Arduino board is not connected — check the USB cable or power.
Fix: The Processing sketch isn’t receiving serial data. Re-upload the Arduino code and ensure the correct port is specified.
This project combines Arduino-based sensor control and Processing-based visualization to simulate a real-time radar scanning system. It demonstrates data acquisition, serial communication, and graphical representation of sensor input — an ideal foundation for robotics, automation, or surveillance applications.