Sunday, January 25, 2015

BobbyBot's First Steps

Repositioned the legs and added duct tape to the feet for a little grip. I am quite surprised how quickly the Arduino and two servo motors burn a 9v battery. I see now why people buy rechargeable batteries and will be investing in some soon. 

Next steps will include programming BB1A to turn (on purpose) walk backward, program the ultrasonic sensor and then set up an obstacle coarse. :)

But... one step at a time. Here are BobbyBot's first steps.

 

Saturday, January 24, 2015

BobbyBot Comes Alive!

Not quite what I had in mind but BobbyBot is ALIVE!

I still need to finess his legs and maybe some of the code because I want him to walk straight and then I will add the sensor to negotiate obstacles...

I now present to BobbyBot (BB1A) dancing a quick jig. 


And here is the code: 

#include <Servo.h> 

Servo frontServo;
Servo backServo;
int centerPos = 90;
int frontRightUp = 72;
int frontLeftUp = 108;
int backRightForward = 75;
int backLeftForward = 105;
void moveForward()

frontServo.write(frontRightUp);
backServo.write(backLeftForward);
delay (125);
frontServo.write(centerPos);
backServo.write(centerPos);
delay (65);
frontServo.write(frontLeftUp);
backServo.write(backRightForward);
delay (125);

frontServo.write(centerPos);
backServo.write(centerPos);
delay (65);

void setup() 
  frontServo.attach(2); 
  backServo.attach(3);  
  } 

void loop() 
{
     moveForward();
     delay(150);

Monday, January 19, 2015

Prototpye BobbyBot

So, with all of the basic functionality and code in place, it is time to begin prototyping my first robot.

(happy dance)

Using the plans laid out in the Make book  referenced earlier, I have begun my first prototype of my first robot whom I will call, BobbyBot. (named after my dog, of course).

Here he is:



Servo Motors

I am kind of blown away. I sat down to program my first servo motor and in 29 minutes I wired and programmed 2 independently moving motors.


Here is the code:


#include <Servo.h> 

Servo myservo1;
Servo myservo2;

int pos = 0;    

void setup() 
  myservo1.attach(9); 
  myservo2.attach(7);  


void loop() 
  for(pos = 0; pos < 180; pos += 1)  
  {                                  
    myservo1.write(pos);              
    delay(15);  
     myservo2.write(pos);              
    delay(15);  
    // waits 15ms for the servo to reach the position 
  } 
  for(pos = 180; pos>=1; pos-=1)     
  {                                
    myservo1.write(pos);              
    delay(15);   
   myservo2.write(pos);              
    delay(15);       
  } 

Liquid Crystal Display

I took a day off yesterday and a bit of a detour today as I wanted to hammer down the Liquid Crystal Display (LCD). I haven't really thought of a practical use for it, but when I found the display in my kit we joked that we would make it say "hello, human!". Our first attempts failed because we didn't know how to use a bread board or a potentiometer. Also, somewhere along the way I had unkowingly burnt out the 5th digital pin on my Arduino. As I write this, I am realizing I have learned quite a bit this month. Pretty cool.

Hello, Human!

Bonus points if you recognize the background (un?)related audio.

Here is the link with all of the info on LCD and Arduino.

And here is the code I used. (I swapped the digital 5 pin for the 7 pin to make mine work.)


#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 7, 4, 3, 2);

void setup() {
  lcd.begin(16, 2);
  lcd.print("hello, human!");
}

void loop() {

  lcd.setCursor(0, 1);
  lcd.print(millis()/1000);
}

Saturday, January 17, 2015

Motion Detector

I feel like I  am moving right along. Today I built a motion detector. The device uses the Ping))) Ultrasonic sensor, LEDs and of course the Arduino. The sensor sends out high frequency sound to detect if there is something in front of it. I plan to use this sensor as the "eyes" of my robot that will be able to detect and overcome obstacles. Again, the lights here represent what will be the motors of of the bot.

Here is a photo: 



















And here is a short video of the motion detector functioning:



And finally,  a quick shout out to Make: Arduino Bots and Gadgets where I retrieved the base of the code. 

/* Ping))) Sensor
 */

const int pingPin = 2;
const int motorPin = 9;
long int duration, distanceInches, distanceCm;
int limitCm = 60;

void setup() 
{
  pinMode(motorPin, OUTPUT);
}

void loop()
{
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);
  
  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  distanceInches = microsecondsToInches(duration);
  distanceCm = microsecondsToCentimeters(duration);
  
  checkLimit();
  delay(100);
}

  void checkLimit()
  {
    if (distanceCm < limitCm){
      digitalWrite(motorPin, HIGH);
    } else {
      digitalWrite(motorPin, LOW);
    }
  }

long microsecondsToInches(long microseconds)
{
    return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
  return microseconds / 29 /2;
}

Pin 5

Just a quick update on the error with PIN 5 that I mentioned in the LED post last week. After several tests using other pin, I have concluded that the 5th pin on my Arduino UNO is not functioning properly and the error was not a result of bad wiring, coding or components. Unless, I come across a reason, my plan going forward is just to skip this pin in future projects.

Friday, January 16, 2015

Beer Bot

So the engineering challenge I posted for myself last weekend was more complicated than I had imagined - but not for what I deemed and obvious reason. I first set out to use a pringles can and set everything up but needed a switch so I had to wait. Today, I swing by Radio Shack (are you really going out of business?? That sucks) and purchased a simple three pin switch and while I was there I picked up a Ping))) Ultrasonic Distance Sensor for this weekends fun. More on that later.

With the switch in play, I rigged up the Pringles can and once everything was in place, I ragged out my wheel gear. I mean, I totally destroyed it in seconds. It seems the wheels were stuck in place. Ugh. But luckily, I had an extra. I decided to switch to a beer can so I could make room for the wheels and that worked, but I don´t have a thing that snaps to the battery. I used old electrical tape that kept slipping... like 10 ten times. I can´t explain how frustrating that is. Lesson learned on that deal.


And now, I present to you my Beer Bot. Enjoy.



(Yes, that is a sock monkey in the background)

Sunday, January 11, 2015

Engineering Challenge

So, going back to my first project I realized that the solar panel manufactured isn´t yet the best source of energy to date. I also noticed that the little car was very instable - speciffically when it ran into Bobby on the first trial run and flipped backward.

I want to create a self propelled machine that can overcome these challenges. Here are the basic parts i have to make my first prototype. What is not featured here is an on/off switch or a ¨POT¨as my cousin suggested. I plan to keep an eye out amongst my things to see if i can salvaje something. Other than that, here are the parts I plan to use.

Light Emitting Diodes



I took my first step into basic robotics today - turning on and off lights. It is a pretty cool step as this concept is the foundation of embedded technology.

What´s that, you ask? Here is an interesting wiki description of the Internet of Things. 

So, anyway, I used the basic circuit technology that I learned last week, added the basic coding with some modifications and came up with two different examples of controling the lights. Now imagine each light represents a motor function on a robot... very exciting.

This is also how people do those crazy christmas light shows like this.

I did have a minor glitch, however. As you watch the video you will notice that the 4th light doesn´t light up. I made all of the obvious adjustments like changing the LED, changing the wire, changing the circuit and checking the code. None of that has worked yet and I hope there isn´t a hardware error on the 5th pin of my Arduino microcontroller... I will report back on that.

So here is my light show...


Here is the code I used for the second progression in the video above:


/*
Blinking LED Lights
*/

void setup () {
pinMode (2, OUTPUT);
pinMode (3, OUTPUT);
pinMode (4, OUTPUT);
pinMode (5, OUTPUT);
pinMode (6, OUTPUT);
pinMode (7, OUTPUT);
pinMode (8, OUTPUT);
pinMode (9, OUTPUT);
}

void loop() {
digitalWrite(2, HIGH);
delay(1000);
digitalWrite(2, LOW);
delay(1000);
digitalWrite(3, HIGH);
delay(1000);
digitalWrite(3, LOW);
delay(1000);
digitalWrite(4, HIGH);
delay(1000);
digitalWrite(4, LOW);
delay(1000);
digitalWrite(5, HIGH);
delay(1000);
digitalWrite(5, LOW);
delay(1000);
digitalWrite(6, HIGH);
delay(1000);
digitalWrite(6, LOW);
delay(1000);
digitalWrite(7, HIGH);
delay(1000);
digitalWrite(7, LOW);
delay(1000);
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(8, LOW);
delay(1000);
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
}

Wednesday, January 7, 2015

Basic Circuit

Basic circuitry has been plaguing my brain. I need to get power to my board so I make my projects work, right? So, I took that last video and broke it down into the smallest parts I can digest in the time I have available and today built a basic circuit. I can´t say it was my first, as I built my first circuit in the late 80s... but hey - that´s been a long time.

I used:
  • A breadboard
  • 9v battery
  • 2 wires
  • 1 LED
  • *a resistor
*The resistor is super important here because without it you will burn out the LED. 

And now I present to you... 

A Basic Circuit. 


Welcome to 1989. 

Thursday, January 1, 2015

Breadboard For Beginners

January 1, 2015

We spent several hours today trying to work with a Liquid Crystal Display (LCD). What we didn't fully contemplate was our inability to work with a breadboard. Frustrated, we put the project away for now. I think we need to take a step back and just work with understanding the breadboard. To that end, I found this video for beginners for next time.


Hello World!

December 30, 2014

The day before I left the states, I bought my first Arduino kit and a book. I spent most of the flight home reading my book and on the 30th I downloaded the software and beginner code called ¨Hello World¨ which just makes a light blink on your Arduino board provino that it indeed does work. After that I rewrote the code myself in an effort to understand the language and played with the amount of time the light estas on and off.

Hello World Code


/*
Blink - Hello World!
*/

void setup () {
pinMode (13, OUTPUT);
}

void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}



Learn more about Arduino here

Solar Cruiser

December 19, 2014

I bought my first robot kit. I use the term robot loosely here. Really, it is much more a construction  toy for kids 8 and up, but I was curious to see what the package entailed and I wanted to have the solar panel and motor. I took it home and assembled it at the kitchen table in under an hour.

Unfortunately, I built it at dusk and was unable to get the motor turning because my family doesn't use halogen light bulbs and the sun had gone down. Initially, I had imagined the solar panel would work under normal lighting like the old calculators. Wrong. I decided at that point that the solar panel that came with the kit would be useless to my future projects.

Nonthelesss, I finally got it to work and it is pretty cool for a first project.




Fun project for kids. Get the kit here.