
The Shadowbot Navigation code is designed for a two-wheel ShadowBot equipped with two proximity sensors, four LEDs, two motors, and two infrared sensors to follow an IR beacon. This README provides an overview of the system, its components, and how to use the provided code.
-
Proximity Sensors: The robot is equipped with two proximity sensors, located on the left and right sides, to detect obstacles and adjust its movement accordingly.
-
LEDs: Four LEDs are used to indicate different states of the robot, such as obstacle detection or successful beacon tracking.
-
Motors: The robot features two motors, each controlled by an H-bridge, enabling it to move forward, backward, turn, and stop.
-
Infrared Sensors: The system includes two infrared sensors that help the robot follow an IR beacon.
-
IR Beacon: An external IR beacon is used as a reference point for the robot's navigation.
The provided code, located in the general.c
file, is structured as follows:
- Configuration settings for oscillator, watchdog timer, low voltage programming, and power-up timer.
- Definition of clock frequency and pin assignments for H-bridge, LEDs, beacon sensors, and encoders.
setpoint_distance
: Minimum distance for obstacle detection.ang2ticks
: Ratio of encoder ticks to degrees.motor_speed
: Motor speed (0-255).
-
readleftADC()
andreadrightADC()
- Read values from left and right proximity sensors using ADC.
-
wait10ms(int del)
- Delay function for
del*10
milliseconds.
- Delay function for
-
turn(int dir, int ang)
- Rotate the robot based on direction (
dir
) and angle (ang
).
- Rotate the robot based on direction (
-
acc(int dir, int dur)
- Accelerate the robot based on direction (
dir
) and duration (dur
).
- Accelerate the robot based on direction (
-
flashLEDs(int dur)
- Flash all LEDs three times over a specified duration.
-
facebeacon()
- Rotate the robot to face the IR beacon.
- Continuous loop where the robot faces the beacon, detects obstacles, and adjusts its movement accordingly.
-
Hardware Setup:
- Connect the proximity sensors, LEDs, motors, and infrared sensors as per the defined pin assignments.
- Place the external IR beacon as the reference point.
-
Code Upload:
- Upload the provided
general.c
code to the microcontroller of the ShadowBot.
- Upload the provided
-
Execution:
- Power on the ShadowBot and observe its behavior.
- The robot will continuously face the IR beacon, detect obstacles, and navigate around them.
- Adjust the
setpoint_distance
,ang2ticks
, andmotor_speed
variables to fine-tune the robot's behavior. - Modify the code within the main loop to add additional behaviors or features.
- The code relies on the availability and proper functioning of the specified hardware components.
- James Bray
- Sam Davis
- Fabian Chrzanowski