ROBO EMOTO

by Kevin_Saslawsky in Circuits > Arduino

140 Views, 2 Favorites, 0 Comments

ROBO EMOTO

DSC07417.JPG

ROBO EMPOTO is a very curious and emotion robot. While in fact useless by nature, ROBO is destine for greater purpose of material manipulation.

Supplies

1x Micro controller (Arduino Uno)

1x L293D DC Motor Drive Shield Stepper Motor Drive Shield

1x Half+ bread board

1x 16x2 row LCD screen

4x AA battery + case

4x DC motor

1x chasse

1x 1000k Potentiometer

1x Passive Buzzer

Many DuPont wires

Give ROBOT EMOTO a Voice

The robot uses a passive buzzer connected to A3 on the motor shield.

CODE__

int buzzerPin = A3;

int maximum = 100;

int buzzDuration = 50;

void setup() {

pinMode(buzzerPin, OUTPUT);
}

void randSound(int maximum){

NewTone(buzzerPin, random(maximum, 10*maximum),buzzDuration); delay(maximum/10); noNewTone(buzzerPin);

}

void Loop () {

randSound();

}

ROBO EMOTO Wants a Face to Express Itself

Robo uses a 16x2 LCD screen to show its current mood. This is based on different "states" that are coded. When more than 20cm away from an object, he is happy. Get any closer and Robot Emoto gets very upset.

CODE_


#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 7, 12, A0);

byte a[]={ B10001, B10001, B10101, B10101, B01010, B00000, B00000, B00000 };

byte b[]={ B00000, B00010, B00100, B01000, B01000, B01000, B01000, B01000 };

byte c[]={ B00000, B01000, B01000, B01000, B01000, B01000, B00100, B00010 };

byte h[]={ B00000, B01000, B00100, B00010, B00010, B00010, B00010, B00010 };

void setup() {

lcd.begin(16,2); lcd.createChar(0,a); lcd.createChar(1,b); lcd.createChar(2,h); lcd.createChar(3,c);

void sadFace() { lcd.setCursor(5,1); lcd.write((char) 3); lcd.setCursor(5,0); lcd.write((char) 1); lcd.setCursor(9,1); lcd.write((char) 201); lcd.setCursor(9,0); lcd.write(2); lcd.setCursor(6,0); lcd.write("x"); lcd.setCursor(8,0); lcd.write("x"); lcd.setCursor(7,1); lcd.write("o"); }

void loop() {

if (distance <= 25){

sadFace(); }

ROBO EMOTO Is Curious and Wants to Bump Into Things

Using the same sensor as the buzzer and the LCD screen, ROBO continues to move forward until it is about to bump into and object. It does this through the readings of the ultra sonic sensor. once it is too close, it stops its motors, turns around, and continues to move forward.

CODE_


#include<AFMOTOR.h>

AF_DCMotor motor1(1,MOTOR34_1KHZ);

AF_DCMotor motor2(2,MOTOR34_1KHZ);

AF_DCMotor motor3(3,MOTOR34_1KHZ);

AF_DCMotor motor4(4,MOTOR34_1KHZ);

void loop() {
delay(50);

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = duration*0.034/2; {

if (distance <= 25){

motor1.setSpeed(0); motor1.run(RELEASE); motor2.setSpeed(0); motor2.run(RELEASE); motor3.setSpeed(0); motor3.run(RELEASE); motor4.setSpeed(0); motor4.run(RELEASE);

motor1.setSpeed(230); motor1.run(FORWARD); motor2.setSpeed(230); motor2.run(FORWARD); motor3.setSpeed(230); motor3.run(FORWARD); motor4.setSpeed(230); motor4.run(FORWARD); delay(2000);

motor1.setSpeed(0); motor1.run(RELEASE); motor2.setSpeed(0); motor2.run(RELEASE); motor3.setSpeed(0); motor3.run(RELEASE); motor4.setSpeed(0); motor4.run(RELEASE); delay(500); }

else {

motor1.setSpeed(230); motor1.run(BACKWARD); motor2.setSpeed(230); motor2.run(BACKWARD); motor3.setSpeed(230); motor3.run(FORWARD); motor4.setSpeed(230); motor4.run(FORWARD); }

}

Now Watch ROBO EMOTO Go!

Full Code

#include

#include #include #define trigPin A1 #define echoPin A2 #define MAX_DISTANCE 200

AF_DCMotor motor1(1,MOTOR34_1KHZ); AF_DCMotor motor2(2,MOTOR34_1KHZ); AF_DCMotor motor3(3,MOTOR34_1KHZ); AF_DCMotor motor4(4,MOTOR34_1KHZ);

LiquidCrystal lcd(8, 9, 4, 7, 12, A0);

int buzzerPin = A3; int notes[] = {262}; int dur = 100; int maximum = 100; long duration; int buzzDuration = 50;

int distance; int distanceUltra;

byte a[]={ B10001, B10001, B10101, B10101, B01010, B00000, B00000, B00000 }; byte b[]={ B00000, B00010, B00100, B01000, B01000, B01000, B01000, B01000 };

byte c[]={ B00000, B01000, B01000, B01000, B01000, B01000, B00100, B00010 };

byte h[]={ B00000, B01000, B00100, B00010, B00010, B00010, B00010, B00010 };

void setup() { Serial.begin(9600); lcd.begin(16,2); pinMode (trigPin, OUTPUT); pinMode (echoPin, INPUT); lcd.createChar(0,a); lcd.createChar(1,b); lcd.createChar(2,h); lcd.createChar(3,c);

pinMode(buzzerPin, OUTPUT); }

void randSound(int maximum){ NewTone(buzzerPin, random(maximum, 10*maximum),buzzDuration); delay(maximum/10); noNewTone(buzzerPin); }

void sadFace() //set lcd faces { lcd.setCursor(5,1); lcd.write((char) 3); lcd.setCursor(5,0); lcd.write((char) 1); lcd.setCursor(9,1); lcd.write((char) 201); lcd.setCursor(9,0); lcd.write(2); lcd.setCursor(6,0); lcd.write("x"); lcd.setCursor(8,0); lcd.write("x"); lcd.setCursor(7,1); lcd.write("o"); } void loop() { delay(50); digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH); distance = duration*0.034/2; Serial.print("distance is _ "); Serial.println(distance); delay (250); lcd.clear();

if (distance <= 25){ motor1.setSpeed(0); motor1.run(RELEASE); motor2.setSpeed(0); motor2.run(RELEASE); motor3.setSpeed(0); motor3.run(RELEASE); motor4.setSpeed(0); motor4.run(RELEASE); motor1.setSpeed(230); motor1.run(FORWARD); motor2.setSpeed(230); motor2.run(FORWARD); motor3.setSpeed(230); motor3.run(FORWARD); motor4.setSpeed(230); motor4.run(FORWARD); delay(2000); sadFace(); randSound(10); delay(500); motor1.setSpeed(0); motor1.run(RELEASE); motor2.setSpeed(0); motor2.run(RELEASE); motor3.setSpeed(0); motor3.run(RELEASE); motor4.setSpeed(0); motor4.run(RELEASE); delay(500); } else { motor1.setSpeed(230); motor1.run(BACKWARD); motor2.setSpeed(230); motor2.run(BACKWARD); motor3.setSpeed(230); motor3.run(FORWARD); motor4.setSpeed(230); motor4.run(FORWARD); } }