Arduino UNO Controlled Quadruped Spider Robot with IR Remote and Battery Power
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This document describes a circuit designed to control a quadruped spider robot using an Arduino UNO microcontroller. The robot has 12 servo motors (3 per leg) and an HC-SR04 ultrasonic sensor for obstacle detection. The circuit is powered by two 18650 Li-ion batteries. The Arduino UNO interprets commands from an IR remote control to move the robot forward, sideways, or make it perform a "hello" gesture.
Component List
Arduino UNO
- Description: Microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
Tower Pro SG90 Servo (x12)
- Description: Small and lightweight servo motor.
- Pins: Signal, +5V, GND
HC-SR04 Ultrasonic Sensor
- Description: Ultrasonic distance sensor.
- Pins: VCC, TRIG, ECHO, GND
18650 Li-ion Battery (x2)
- Description: Rechargeable lithium-ion battery.
- Pins: +, -
Wiring Details
Arduino UNO
- 5V: Connected to +5V of all 12 Tower Pro SG90 servos and VCC of the HC-SR04 Ultrasonic Sensor.
- GND: Connected to GND of all 12 Tower Pro SG90 servos, GND of the HC-SR04 Ultrasonic Sensor, and - of the 18650 Li-ion Battery.
- Vin: Connected to + of the 18650 Li-ion Battery.
- A0: Connected to Signal of one Tower Pro SG90 servo.
- A1: Connected to Signal of one Tower Pro SG90 servo.
- D13: Connected to Signal of one Tower Pro SG90 servo.
- D12: Connected to Signal of one Tower Pro SG90 servo.
- D11: Connected to Signal of one Tower Pro SG90 servo.
- D10: Connected to Signal of one Tower Pro SG90 servo.
- D9: Connected to Signal of one Tower Pro SG90 servo.
- D8: Connected to Signal of one Tower Pro SG90 servo.
- D7: Connected to Signal of one Tower Pro SG90 servo.
- D6: Connected to Signal of one Tower Pro SG90 servo.
- D5: Connected to Signal of one Tower Pro SG90 servo.
- D4: Connected to Signal of one Tower Pro SG90 servo.
- D3: Connected to ECHO of the HC-SR04 Ultrasonic Sensor.
- D2: Connected to TRIG of the HC-SR04 Ultrasonic Sensor.
Tower Pro SG90 Servo (x12)
- Signal: Connected to various pins on the Arduino UNO (A0, A1, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4).
- +5V: Connected to 5V on the Arduino UNO.
- GND: Connected to GND on the Arduino UNO.
HC-SR04 Ultrasonic Sensor
- VCC: Connected to 5V on the Arduino UNO.
- TRIG: Connected to D2 on the Arduino UNO.
- ECHO: Connected to D3 on the Arduino UNO.
- GND: Connected to GND on the Arduino UNO.
18650 Li-ion Battery (x2)
- +: Connected to Vin on the Arduino UNO.
- -: Connected to GND on the Arduino UNO.
Code Documentation
/*
* This Arduino sketch controls a quadruped spider robot with 3 servo motors
* per leg, using an IR receiver to interpret commands from a remote control.
* The robot moves forward if the up arrow is pressed, sideways if the left or
* right arrow is pressed, and says hello with one leg if the number 1 is
* pressed.
*/
#include <Servo.h>
#include <IRremote.h>
#define FORWARD 0xFF629D
#define LEFT 0xFF22DD
#define RIGHT 0xFFC23D
#define HELLO 0xFF6897
const int RECV_PIN = 12;
IRrecv irrecv(RECV_PIN);
decode_results results;
Servo servos[12];
void setup() {
irrecv.enableIRIn();
for (int i = 0; i < 12; i++) {
servos[i].attach(i);
}
}
void loop() {
if (irrecv.decode(&results)) {
switch (results.value) {
case FORWARD:
moveForward();
break;
case LEFT:
moveLeft();
break;
case RIGHT:
moveRight();
break;
case HELLO:
sayHello();
break;
}
irrecv.resume();
}
}
void moveForward() {
for (int i = 0; i < 12; i++) {
servos[i].write(90);
}
delay(1000);
for (int i = 0; i < 12; i++) {
servos[i].write(0);
}
delay(1000);
}
void moveLeft() {
for (int i = 0; i < 6; i++) {
servos[i].write(90);
}
delay(1000);
for (int i = 0; i < 6; i++) {
servos[i].write(0);
}
delay(1000);
}
void moveRight() {
for (int i = 6; i < 12; i++) {
servos[i].write(90);
}
delay(1000);
for (int i = 6; i < 12; i++) {
servos[i].write(0);
}
delay(1000);
}
void sayHello() {
servos[0].write(90);
delay(1000);
servos[0].write(0);
delay(1000);
}
This code initializes 12 servo motors and an IR receiver. It listens for IR commands and moves the servos accordingly to make the robot move forward, left, right, or perform a "hello" gesture.