Simple Uncordinated Robot Creature With Arduino
by ydong02 in Circuits > Electronics
268 Views, 1 Favorites, 0 Comments
Simple Uncordinated Robot Creature With Arduino
This project is inspired by the uncoordinated robot dogs I see on social media, though it's much simpler in execution. It mostly uses parts from the ELEGOO UNO Project Starter Kit to replicate the stumbling motion of the robotic dogs.
Downloads
Supplies
From the Arduino kit:
- 1 x Elegoo Uno R3
- 1 x 830 Tie-points Breadboard
- 2 x 220 ohm resistor
- 1 x push switch
- 6 x M-M wires (Male to Male jumper wires)
- 1 x Servo (SG90)
External materials:
- 1 x bamboo skewer
- hot glue gun (with hot glue sticks)
Adding Creature Features to Servo
To create the head of the creature, cut off 1cm from the sharpened tip of the bamboo skewer and insert it into the fan. Glue the end of the stick to the screw end of the servo motor, and then glue two resistors to the body of the servo motor to substitute for legs.
Wiring
Servo Wiring
In the picture, the brown wire of the servo is adapted via the black M-M wires, the red one is adapted via the red M-M wires, and the orange one is adapted via the yellow M-M wires. The red wire should feed into the 5v port on the analog side of the Arduino, the yellow feeds into the digital #9 port, and the black wire goes along the negative rail on the breadboard. Connect a separate black M-M wire from the negative breadboard rail to the GND pin on the digital side of the Arduino to ground the servo.
Button Wiring
Insert the button into the middle of the breadboard. A blue M-M wire connects the button to the digital #9 port on the Arduino while a black M-M wire connects it to ground (indirectly along the negative rail on the breadboard).
Code
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
int buttonPin = 8;
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
Serial.begin(9600);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
// if button is pressed
if (digitalRead(buttonPin) == LOW) {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(1); // waits 1ms for the servo to reach the position
}
delay(50);
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos);
delay(1);
}
}
}
Paste this code into a new sketch within the Arduino software. If the servo.h library has not yet been installed, you may need to download and then include the zip file. Upload the program to your Arduino, and press the button on the breadboard to finally activate your robot!