Introduction: Cutey the Arduino Robot.
These are cuteys electronics, there is a arduino mega, HC-SR04 sensor, two modified robot servos with wheels, arduino sensor shield, and wires.
Cutey is a autonomous robot with a twist, HE WANTS FRIENDS!
He will spin around until you put your hand in front of him then he will follow you, so don't put him in front of a wall.
Step 1:
The servos are connected together with a LEGO piece and hot glue, for easy mounting.
Step 2:
Right servo cable to the sensor shield digital 11, left servo cable to the sensor shield digital 10.
Step 3:
Make the wheels by hot gluing together the servo hub to the wheels.
Step 4:
HC-SR04 Trig pin to pin 52 on arduino mega and echo to 50.
Step 5:
here is the code.
#include <Servo.h>
Servo myservo;
Servo myservo2;
const int pingPin = 50;
const int pingPin2 = 52;
void setup() {
Serial.begin(9600);
myservo.attach(10);
myservo2.attach(11);
}
void loop()
{
long duration, inches, cm;
pinMode(pingPin2, OUTPUT);
digitalWrite(pingPin2, LOW);
delayMicroseconds(2);
digitalWrite(pingPin2, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin2, LOW);
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
if(inches < 5){
myservo.writeMicroseconds(2000);
myservo2.writeMicroseconds(2000);
}
if(inches > 5){
myservo.writeMicroseconds(1000);
myservo2.writeMicroseconds(1000);
}
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
long microsecondsToInches(long microseconds)
{
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}
Participated in the
Hardware Hacking