Wednesday, May 28, 2014

ROBOcop #2

Step 1: materials
  • Robot built previously in project 3
  • Arduino Uno
  • Batteries
  • Sound Sensor 
  • 220 and 10K resistors
Step 2: Physical Building
  • I already had ROBOcop built so that was done
  • I started by adding wiring to make him make a noise when the sensor read motion.
 Step 3: Code

void setup() {
  Serial.begin(9600);
  Serial.println("Playing higher pitch tone...");
  pitch(3500); // pitch function call passes 3500 to Hz parameter
  delay(1000);
  Serial.println("Playing lower pitch tone...");
  pitch(2000); // pitch function call passes 2000 to Hz parameter
  delay(1000);
  }
 
void loop() {
}

void pitch(int Hz)
// pitch function with Hz declared as a parameter
{
Serial.print("Frequency = "); Serial.println(Hz);
tone(4, Hz, 1000); delay(1000);
}

Reflection

I couldn't get this project to work for some reason. I wish I did have more time to focus on at least getting it working. However, the process in building this was very fun and I regret nothing.

Crystal Ball

Step 1: Materials
  • Arduino Uno
  • Breadboard
  • Jumper wires
  • Petentiometer
  • Tilt Switch
  • Crystal Ball Monitor/Sensor
Step 2: Physical Building
  • First I attached the Crystal Ball Monitor to the breadboard and attached it all to ground and power.
  • Then I attached all the appropriate wires to make the sensor turn on.
  • I inserted the tilt switch and the potentiometer to power as well
  • Then I moved on to the code
Step 3: Code

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int switchPin = 6;
int switchState = 0;
int prevSwitchState = 0;
int reply;

void setup() {
  lcd.begin(16, 2);
  pinMode(switchPin, INPUT);
  lcd.print("Ask the");
 
  lcd.setCursor(0, 1);
  lcd.print("Crystal Ball!");
}

void loop() {
  switchState = digitalRead(switchPin);
 
  if (switchState != prevSwitchState) {
    if (switchState == LOW) {
      reply = random(8);
     
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("The ball says:");
      lcd.setCursor(0, 1);
     
      switch(reply){
        case 0:
        lcd.print("Yes");
        break;
        case 1:
        lcd.print("Most likely");
        break;
        case 2:
        lcd.print("Hell no");
        break;
        case 3:
        lcd.print("Ask again..");
        break;
        case 4:
        lcd.print("Certainly");
        break;
        case 5:
        lcd.print("Nope");
        break;
        case 6:
        lcd.print("Looks good");
        break;
        case 7:
        lcd.print("Sorry not sorry");
        break;
      }
    }
  }
 
  prevSwitchState = switchState;
}


Reflection

This program frustrated me because I had a hard time understanding what the petentiometer was and what it did. Also I found and error in my code that was causing the screen not to work. This project was a fortune telling device. Kind of like a magic 8-ball, with sassy responses and all. I enjoyed experimenting with the Crystal Ball Sensor.

ROBOcop

Step 1: Materials
  • Arduino Uno
  • Robot Kit
  • AA+ batteries
Step 2: Physical Building
  • So this actually took me awhile because I had to actually screw things together and "build" the robot.
  • After that I Added the external Arduino Uno that doesn't come with the kit and put in batteries so it could run without the wire...however the batteries were dead and I am flat broke so I had to keep the wire in.
  •  
Step 3: Code

#include <Servo.h>
Servo servoLeft;
Servo servoRight;

void setup() {
  tone(4, 3000, 1000);
  delay(1000);
 
  servoLeft.attach(13);
  servoRight(12);
 
  servoLeft.writeMicroseconds(1700);
  servoRight.writeMicroseconds(1300);
}

Reflection

I really enjoyed building this. All it did was go in a circle and even so I was very happy that it worked and that I had programmed and built it right. It did exactly what I wanted it too... I only wish I had more time to play around with it. My robots name was ROBOcop

This Love

Step 1: Materials
  • Arduino Uno
  • Breadboard
  • Jumper wires
  • LED lights
  • RGB light
  • Button / Switch
  • 220 resistors
Step 2: Physical Building
  • I started by connecting the breadboard to power and ground
  • Then I inserted the LEDs and connected them accordingly - along with resistors
  • Next I did the same for the RGB light.
  •  Finally I wired in the switch.
Step 3: Code

I forgot to save my code for this one so it is lost. Basically what this program did was play the first few beats of the song "This Love" by Maroon 5. I got this idea from a quick project we did in class one day but in order to make it my own I made is longer and different patterns.

Reflection
My goal for this project was to create a simple yet enjoyable program that combined two things I love Maroon 5 and programming. I really enjoyed perfecting the beats "played" by the lights. Looking back I wish I had programmed it to make sound as well, but this was just as challenging and fun without that.



Love-O-Meter






For my first project I wanted to create a temperature reader that made LEDs turn on depending on the temperature read by the sensor.

Step 1: The Materials
  • Arduino Uno
  • Breadboard
  • 3 red LEDs
  • Jumper wires
  • Temperature Sensor
Step 2: Physical Creative
  • To start I connected the breadboard to GND (ground) and 5V (voltage)
  • Next I inserted the LEDs, 2 220 resistors for each and 3 yellow jumpers to attach them to the Arduino
  • Then I inserted the TMP (temperature) sensor and the appropriate jumpers for that as well.
Step 3: Code

const int sensorPin = A0;
const float baselineTemp = 20.0;

void setup(){
  Serial.begin(9600); //open a serial port
  for(int pinNumber = 2; pinNumber<5; pinNumber++){
    pinMode(pinNumber, OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}

void loop(){
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor Value: ");
  Serial.print(sensorVal);
 
  //convert sensor reading to voltage
  float voltage = (sensorVal/1024.0) * 5.0;
  Serial.print(", Volts: ");
  Serial.print(voltage);
  Serial.print(", degrees: ");
  //convert voltage to temp
  float temperature = (voltage - .5) * 100;
  Serial.println(temperature);
 
  if(temperature < baselineTemp){
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  }else if(temperature >= baselineTemp+2 && temperature < baselineTemp+4){
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  }else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6){
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
  }else if(temperature >= baselineTemp+6){
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
  }
 
  delay(3);
}

Reflection:

This was day 1 of the Arduino Project. I did not focus on one project and expand because I wanted to see how many different programs I could discover. I had some difficulty with the temperature sensor and I had to work on it outside of class. There was a point when the temperature sensor actually became burning hot and actually burned me...so I figured something wasn't right. After a few adjustments in my code I was able to get my "Love-o-meter" working.