Dependencies:   mbed Motor mbed-rtos

Useless Robot

Useless Robot Overview

Project by Austin Bartmess and Jeremy Deremer

This is a robot developed on an ARM Microcontroller (LPC 1768). It uses a servo, two DC motors both powered by an external power source, nine red LEDs, two RBG LEDs, a speaker, a toggle switch and a transistor.

The goal of this robot is to stay off. However, the user can turn it on without harm. It attempts to stay off via turning a toggle switch off with an arm attached to a servo. If the robot is turned on too much, it will progressively get angry. It starts by not smiling and changing eye colors. Following that, the robot will frown and yell at the user. Finally, the robot will drive around randomly while screaming and looking angry via its LEDs.

Required Parts

  • mbed Microcontroller x1
  • USB to mini USB cable x1
  • Servo x1
  • H-Bridge Breakout Board x1
  • DC Motors x2
  • DC Motor Wheels x4
  • Red LEDs x9
  • RGB LEDs x2
  • 0.5W Speaker x1
  • Toggle Switch x1
  • BJTransistor x1
  • Jumper Cables Kit x1
  • Breadboard x2

Pinout and Connections

MbedH-BridgeDC MotorsServoTransistorSpeakerLEDsBarrel JackToggle Switch
GNDGND(-)Emitter(-)GND(-)(-)
Vu
VinVm(+)(+)
VoutVcc, /STBY(+)
p5AIN1
p6AIN2
p10LED+
p11LED+
p12LED+
p15Control
p21PWMA
p22Collector
p23Blue
p24Green
p25Red
p26Control
AO1(+)
AO2(-)

/media/uploads/jderemer3/capture.png

Demo Clip

Source Code

Import program4180_FinaProject

main.cpp

Committer:
jderemer3
Date:
2017-04-26
Revision:
0:4931c25e1cf7
Child:
1:0402db7e91f5

File content as of revision 0:4931c25e1cf7:

#include "mbed.h"
#include "rtos.h"
#include "RGBLed.h"
#include "uLCD_4DGL.h"
 
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);

// RGBLed myRGBled(p21,p22,p23); //RGB PWM pins

Serial bluemod(p28,p27);
PwmOut red(p21);
PwmOut green(p22);
PwmOut blue(p23);

uLCD_4DGL uLCD(p9, p10, p11);

Thread t1; // Arm Response
Thread t2; // LED Color
Thread t3; // Speaker Music / Audio
Thread t4; // Motor Control

Mutex lk_LCD;
 
void rgb_t3() {

    while (true) {
        
    }
}

void lcd_t1() {
    while (true) {
        for (int i = 0; i < 10; i++)
        {
            lk_LCD.lock();
            uLCD.locate(2,2);
            uLCD.printf("\n Hello World! \nCount by one is %d!\n", i);
            lk_LCD.unlock();
            Thread::wait(1000);
        }
    }
}

void lcd_t2() {
    while (true) {
        for (int j = 0; j < 20; j += 2)
        {
            lk_LCD.lock();
            uLCD.locate(4,4);
            uLCD.printf("\n Hello World! \nCount by two is %d!\n", j);
            lk_LCD.unlock();
            Thread::wait(2000);
        }
    }
}
 
 

int main() {
    // myRGBled.write(0.0, 0.0, 0.0);  
    char bred=0;
    char bgreen=0;
    char bblue=0; 
    red = green = blue = 0;
    
    t3.start(rgb_t3);
    t1.start(lcd_t1);
    t2.start(lcd_t2);
    
    while (true) {
        if (bluemod.getc()=='!') {
            if (bluemod.getc()=='C') { //color data packet
                bred = bluemod.getc(); // RGB color values
                bgreen = bluemod.getc();
                bblue = bluemod.getc();
                if (bluemod.getc()==char(~('!' + 'C' + bred + bgreen + bblue))) { //checksum OK?
                    red = bred/255.0; //send new color to RGB LED PWM outputs
                    green = bgreen/255.0;
                    blue = bblue/255.0;
                }
            }
        }
        led1 = !led1;
        Thread::wait(500);
    }
}