This project is a cart that moves towards the IR receiver and avoids obstacles.
- Any Arduino board with at least few digital pins.
- Motor shield to control the motors.
- IR receiver like TSOP3838.
- Ultrasonic sensor like HC-SR04.
- (Optional) Bluetooth module like HC-05.
- 9V battery to power the motors and Arduino.
- Any supporting hardware like motors, wheels, chassis, etc.
- Arduino IDE or PlatformIO.
- Clone this repo branch using
gh repo clone <repo> -- --branch <branch>
. - Open the project in Arduino IDE or PlatformIO.
- Build the cart using the hardware mentioned in the requirements.
- In your IDE, select the correct board and port:
- In PlatformIO, edit
platformio.ini
and set the correct board and port. - In Arduino IDE, select the correct board and port from the Tools menu.
- In PlatformIO, edit
- Build the project:
- In PlatformIO, click on the "Build" button in the toolbar or use the
PlatformIO: Build
command from the command palette. - In Arduino IDE, select
Sketch > Verify/Compile
from the menu.
- In PlatformIO, click on the "Build" button in the toolbar or use the
- Upload the project to your Arduino board:
- In PlatformIO, click on the "Upload" button in the toolbar or use the
PlatformIO: Upload
command from the command palette. - In Arduino IDE, select
Sketch > Upload
from the menu.
- In PlatformIO, click on the "Upload" button in the toolbar or use the
- Power the Arduino and the motors using the 9V battery.
- You can start and stop the cart using the bluetooth module by sending the commands
ON
andOF
respectively. - The cart will move towards the IR receiver and avoid obstacles according to the state machine implemented in the GuidedCart class.
- You can change a few parameters in the GuidedCart header file to adjust the cart's behavior.
- The IR receiver can receive reflections from the walls and other objects, which can cause the cart to move in the wrong direction.
- Ultrasonic sensors can sometimes give false readings, which can cause the cart to stop unnecessarily.
- Cart can get stuck in a loop if it cannot find a clear path to the IR receiver.
- The search IR state can sometimes cause rotation that does not return to the original position.
You can run the tests using the PlatformIO test framework. To run the tests, follow these steps:
- Make sure to follow the build steps mentioned above.
- Run the tests:
- In Clion, open the terminal and run the command
pio test -e 'env'
. - In Visual Studio Code, there are two ways to run the tests:
- Use the PlatformIO toolbar on
advanced->Test
and select the environment. - Open the terminal and run the command
pio test -e 'env'
.
- Use the PlatformIO toolbar on
- In Clion, open the terminal and run the command
This project is licensed under the MIT License - see the LICENSE file for details.