My first Arduino project. This is a four-wheel car with 3 modes:
- Auto: Obstacle avoiding
- Manual: Bluetooth controlling
- Manual: Infrared controlling
Unlike many tutorials on the internet, I build my robot to stop automatically without having to press any stop button
. If I want the robot to run, I'll just hold the button on the controller and release it when i don't want to. Therefore, the robot become easier to control o.<
Image | Name |
---|---|
Kid's engineering kit | |
Soldering iron | |
Hot glue gun | |
Jumper wires | |
Infrared remote control |
Notes:
- I only use the short L-shape bracket in the engineering kit. You can buy a mounting bracket for ultrasonic sensor, which is way better :3
- You can use any IR remote, just make sure to edit the buttons' hex value in the code before uploading it to Arduino. I use the remote shown above and its hex codes are:
#define ON 0xFFA25D
#define OFF 0xFFE21D
#define MODE1 0xFFE01F
#define MODE2 0xFFA857
#define MODE3 0xFF906F
#define SOS 0xFF18E7
#define HOLD 0xFFFFFFFF // Generally, remote will send this value when you're holding a button
Connect IR receiver module with Arduino like this
Then plug in the USB cable to upload the code.
#include <IRremote.h>
#define RECV_PIN 2 // Specifying the pin connected to receiver module
IRrecv irrecv(RECV_PIN);
decode_results button;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn(); // Initialization to receive IR signals
}
void loop(){
if(irrecv.decode(&button)){ // Store decoded signal in `button`, return 0 if nothing is received
Serial.println(button.value); // Print the value to the serial monitor
irrecv.resume();
}
}
On Arduino IDE, go to Tools
-> Serial Monitor
(or press Ctrl+Shift+M) then press the buttons on the remote respectively to get their Hex values on the monitor.
-
Arduino IDE
-
Any Arduino bluetooth controller app.
I chose Arduino Bluetooth Controlled Joystick. Besides two joystick modes and one accelerometer mode, this app provides
Button Mode
- the mode i'm using in this project. I use the default setting in the app:Button Symbol Character send Up arrow ˄ N Down arrow ˅ S Left arrow ˂ W Right arrow ˃ E Cross X 1 Circle O 2 Triangle Δ 3 Square □ 4