Introduction: THE EMOTIONAL OBSTACLE AVOIDING ROBOT

The emotional robot. This robot displays emotions with neopixels (RGB LED's) such as sadness,happiness,angry and scared, it can also avoid obstacles and do certain movements during its certain emotion. The brains of this robot is an Arduino mega. keep in mind this is my first programmed robot I had ever built, and its made me fall in love with programming, the code itself is very beginner and could most likely be simplified.

Step 1: PARTS

-3.2ft of a neopixel strip

-HC-SR04 Ultrasonic Sensor(or any other ultrasonic sensor)

-tilt switch

-3 3.7v lithium ion battery(18650)

-boost converter(explained in power step)

-photo resistor(any value)

-analog sound sensor

-2 dc motors 6v

-l293d (motor driver)

-plastic sheet

-cardboard

-caster wheel

Step 2: Neopixels

Due to how I was on a tight budget the simplest and cheapest way to make my robots emotions come to life are neopixels, all they have is 3 inputs and outputs. the three pins on the input are labelled 5v,DIN(data in) and GND(ground); the output is labeled the same as input but instead of data in its DO(data out). The way you connect these led is to connect them in parallel with each other, so 5v connects to 5v on the other led and GND is connected to the other led GND, DO of the first led is connected to DIN of the second led and then this process continues until you hit your desired led strip length. An entire strip of neopixels only requires one digital output pin from the input, this is because the DO and DIN are connected in a long chain, so they all share data with each other. This is necessary because we need to turn specific leds on and off at specific times. A helpful instructable on this is NEOPIXEL HELP

Step 3: The Schematic

The circuit is very simple as most of the robot is just programmed, the motors run on close to 7v with a l293d motor driver in order to control the motors to go forward of backward. The other connections are the sensors to the Arduino. And that's it!

Step 4: The Code

The first thing I did was to download the required libraries to make the coding a little easier, the libraries i used are "FastLED.h" and "NewPing.h". The fast led one is for the leds and the new ping one is for the ultrasonic sensors. The next thing I did was make all the definitions for the pins i used, after that was void setup this is where I set up the pin modes and the neostrip "FastLED.addLeds(leds, NUM_LEDS);" i defined the NUM_LEDS as 56, since i used 56 leds, the configurations of the leds will be explained in the face step. I then created a bunch of functions for my robot to move forward and back and also have its certain emotion, after that i come to the void loop, this is where i call all my functions in a certain sequence that i want, for example, if i wanted my robot to smile then i would put smile();. If i wanted a certain led to turn on i would put, leds[45] = CRGB::Green; , this will set led 45 to be green. When i put the colour to black, it just means off. Now keep in mind that this is one of my first programs so its obviously not perfect, but it still worked.

THE CODE

Step 5: The Face

For the face I used 56 leds which is almost a full 3.2ft neopixel strip. I cut the strip into 7 strips of 8 leds, I used the first 3 strips for the eyes and the last 4 for the mouth. I connected the strips in a snake form kind of connection, you'll understand better with the diagram hopefully. When i finished the face I then put a thin plastic sheet(about a 2mm thick) over the led strips.

Step 6: Happy Function

This function is the easiest of them all as it doesn't use any sensors, instead as soon as you power up the bot , it instantly smiles at you. But it doesn't only smile; when its smiling, its in obstacle avoiding mode as well. Obstacle avoiding mode is represented in my code as the function roam. The obstacle avoiding mode or roam works by using two ultrasonic sensors on the robots side, when the sensor comes 30cm to anything it would back up and either go right or left depending on the sensor that's closest to the object.

Step 7: Sad Function

In order for the robot to become sad I had to think of a personality trait for this robot, so i decided to make him sad when hes in a dark environment. To do this I used a photo resistor to sense light. The darker the environment the higher the resistance and the lighter the environment the lower the resistance. The circuit works as a voltage divider which is a circuit with two resistors connected in series to +5v and GND, at the midpoint of the resistor connection lies a voltage which can be determined by this equation: input voltage*(R2/R1+R2). when the Arduino Analog Pin reads this value it converts the voltage into a range from 0 to 1023.

Step 8: Angry Function

In order to make the robot angry I decided on flipping/knocking it over. This works by using a tilt switch, and a tilt switch is basically a normal switch but instead of have a button or rocker, you have a mercury ball which if tilted at a certain angle will connect the two contacts and turn on; so the value from this is either 0 or 1, 0 for off and 1 for on. When the robot is angry it also ignores the obstacle avoiding mode and rams anything in sight in the forward direction, due to its anger.

Step 9: Scared Function

For the final function of the robot is the scared function, which uses a sound sensor which is placed right on top of the robot. Whenever the robot hears a load noise it will get scared and shiver while going backwards. The sound sensor works by using a condenser mic which is a microphone, when it senses sounds or vibrations it will create a small voltage, usually about 100mv, this voltage is then amplified and read through the analog pin of the Arduino, the higher the voltage or louder the sound the higher the analog value, and vice versa.

Step 10: Power

Now that you built everything you need to power it, i originally tried to power this with 8 AA batteries, but was just too bulky and impractical. I then used 3 lithium ion batteries which each hold about 3.5v, I connected one battery to a boost converter which is a voltage booster, this boosted my 3.5v to 5v to power the Arduino, I then used two of the batteries and directly connected it to the motors and LED's , this is not such a good idea since the voltage wasn't regulated, but I didn't have a voltage regulator laying around, if you try and build this i recommend using a voltage regulator than can do 5v at around 2-3 amps, an example of this is the LM78S05. Or you can use the LM7805 to power the Arduino and instead get a step down converter or buck converter to lower the voltage and power the LED's and motors.

Step 11: Have Fun!!!

I hope you build this robot and have a fun time, I also hope you will put your own spin on this robot and create your own emotions to make it ALIVE!!!


VIDEO OF BOT IN ACTION sorry I didn't show all the functions of the bot in the video.


Robotics Contest

Participated in the
Robotics Contest