Introduction: FANtastic

FANtastic is a "flirty" robot. It gets your attention by making a beeping sound and calling you to come closer, but when you go to have a look, it stops working, its nose changes colour from green to red and it tells you to go away. However it has a second fan on its back that turns on as soon as the front one stops, when you go to the other side to check it out, the front side changes its mind and starts calling you again, making annoying sounds, trying desperately to get your attention.

Step 1: Parts

Step 2: The Circuit

This is what we are going to do… Don’t panic, it’s not as scary as it looks :)

Step 3: ​RGB-LED

Let’s start with the least scary part - the RGB LED. Unlike regular LEDs that have only one color, the RGB LED actually has three leds inside(red, green, blue). By controlling their brightness you can mix almost any color you want. We use only the red and the green to show the mood of our FANtastic robot: green = happy... , red = angry, annoyed.
The very first thing to do is to connect the breadboard to the arduino. We do that by connecting the + of the breadboard to the 5v and the - to the GND (ground). The RGB-LED has four legs. The longest one is the ground. On its left side is the red leg. On the other side of the ground are green and blue. The LED needs a lower currency than the 5V of the arduino. We use resistors of 1k to lower the voltage. The red leg is connected to digital pin 13, the green one to 12. Blue is not used here. The ground goes to the minus on the breadboard.

Step 4: Ultrasonic Sensor

For the next step you will need an ultrasonic sensor and four jumper wires. The sensor is used to measure the distance to an object through sound waves sent from one of the openings on the front. The other opening receives them. The distance is calculated by timing how long it takes for the echo of the sound to come back. Connect the TRIG to digital pin 11 and the ECHO to pin 12 first, then to the power (5V) and the Ground as shown in the diagram.

Step 5: Active Buzzer

The buzzer is used to generate an annoying sound, to get your attention as soon as you turn away from the robot. Place the buzzer in the breadboard. Connect the + to the power. The other leg of the buzzer is connected to the digital pin 9.

Step 6: LCD Display

To let the robot talk to us we use the LCD Display, showing messages. You can make the robot say anything as long as it’s not more than 16 characters. To save digital pins we've connected the LCD Display connected to the row of analog pins. The analog can work as digital ones, but the digital canNOT work as analog pins. Set up the wires as shown in the diagram. The potentiometer (10k) regulates the brightness of the display. You can connect it externally or place and connect it within the breadboard.

Step 7: DC Motors

Fans are essential for making the FANtastic robot! To power them you will need two DC motors. The L293D chip lets you control the motors separately. Start by placing it in the middle of the breadboard and use the wires to connect it as you see in the picture. If you prefer to have a different set up always make sure to use one of the PWM ~ pins to connect each motor to the Arduino. They allow you to control the speed of the motor. Stick a propeller on each of the motors to create the fans.

Step 8: The Code

int enable1 = 5;
int dir1 = 4;
 
int enable2 = 3;
int dir2 = 2;

// sr04 - distance sensor
#include "SR04.h"
#define TRIG_PIN 11
#define ECHO_PIN 10
SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN);
long a;

//LED
// Define Pins
#define GREEN 12
#define RED 13

//LCD Display
// include the library code:
#include 
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);

void setup() 
{
 
  // motors
  pinMode(enable1, OUTPUT);
  pinMode(dir1, OUTPUT);
  pinMode(enable2, OUTPUT);
  pinMode(dir2, OUTPUT);

  Serial.begin(9600);

 //LED
  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  digitalWrite(RED, HIGH);
  digitalWrite(GREEN, LOW);

 //LCD Display
 lcd.begin(16, 2); // set up the LCD's number of columns and rows

 //Piezo
 // declare pin 9 to be an output:
  pinMode(9, OUTPUT);
  beep(50);
  beep(50);
  beep(50);
  delay(1000);
}

// define variables
int redValue;
int greenValue;</p><p>void loop() 

{
 a=sr04.Distance();
   Serial.print(a);
   Serial.println("cm");
   //delay(100);

 if (a<=50)
{  

//LED
    analogWrite(GREEN, 0);
    analogWrite(RED, 255);
    // Print a message to the LCD.
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("get away");
    //lcd.print("get away");

digitalWrite(dir1, HIGH);
digitalWrite(dir2, LOW);

analogWrite(enable1, 50);
delay(500);
analogWrite(enable1, 150);
delay(500);
analogWrite(enable1, 255);
delay(500);
beep(0);
    
    //delay(300);
  }   
  else if (a>=50){

  analogWrite(RED, 0);
    analogWrite(GREEN, 255);
    // Print a message to the LCD.
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("hey baby");

   digitalWrite(dir1, LOW);
   digitalWrite(dir2, HIGH);
   beep(100);
   beep(100);
   
   analogWrite(enable2, 50);
   beep(200);
   delay(500);
   
   analogWrite(enable2, 150);
   beep(200);
   delay(500);
   
   analogWrite(enable2, 255);
   beep(200);
   delay(500);    

}
}

void beep(unsigned char delayms)
{
  analogWrite(9, 20);      // Almost any value can be used except 0 and 255
                           // experiment to get the best tone
  delay(delayms);          // wait for a delayms ms
  analogWrite(9, 0);       // 0 turns it off
  delay(delayms);          // wait for a delayms ms  
  
}

Step 9: Have Fun

Use foam core to create the body of the robot. Use your fantasy to create different shapes and faces.Be careful not to disconnect anything while embedding the electronics inside. Make it FANtastic!

Mona Mühlich

Denitsa Koleva