Thursday, January 15, 2015

Electronics Final: Robotic Car

Robotic Car
By; Warren and Dane

So our project was to wire and program an electric car to respond to infared signals allowing it to move forwards, move backwards, turn left, turn right and stop and start. At first we created a randomized program which caused the car to move randomly around the room. However, this part was not included in our final design. Here is a video of the car in action:
This video here explains the wiring of the infared sensor and the motors:




#include <IRremote.h>      // include database for infared receiver
int INA = 4;                       //set up pin numbers for direction of motors and speed of motors
int PWMA = 5;
int INB = 7;
int PWMB = 6;
int RECV_PIN = 11;         // input number for infared receiver

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  pinMode(INA,OUTPUT);      // motor 1 output
  pinMode(INB,OUTPUT);      // motor 2 output
  analogWrite(PWMA,255);    // motor 1 speed
  analogWrite(PWMB,255);    // motor 2 speed
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {                       // recieve results
    if (results.value == 0xFF807F)                  // if infared recieves the forward button code do this code
     {
      Serial.println("forward");                  
      digitalWrite(INA,HIGH);                        // both motors move forward
      digitalWrite(INB,HIGH);
      delay (200);
      irrecv.resume();                                       // recieve another input
      while (results.value == 0xFFFFFFF)     // while the sensor continues to recieve same input........
      {
        digitalWrite(INA,HIGH);                   // continue moving forward
        digitalWrite(INB,HIGH);
        irrecv.resume();                                      
      }
      
    }
    if (results.value == 0xFF8877)                      // if infared recieves the right button code do this code
    {
      Serial.println("right");
      digitalWrite(INA,LOW);                       // causes car to turn right
      digitalWrite(INB,HIGH);
      delay (200);
      irrecv.resume();                                         // recieve another input
      while (results.value == 0xFFFFFFF)     // while the sensor continues to recieve same input........
      {
        digitalWrite(INA,LOW);                         // continue turning right
        digitalWrite(INB,HIGH);
       
      }
      
    }
    if (results.value == 0xFF906F)    // if infared recieves the backward button code do this code
    {
      Serial.println("backwards");
      digitalWrite(INA,LOW);                 // causes car to drive backwards
      digitalWrite(INB,LOW);
      delay (200);
      irrecv.resume();                                 // recieve another input
      while (results.value == 0xFFFFFFF)   // while the sensor continues to recieve same input........
      {
        digitalWrite(INA,LOW);       // continue moving backwards
        digitalWrite(INB,LOW);
        
         irrecv.resume();
      }
      
    }
    if (results.value == 0xFF9867)       // if infared recieves the left button code do this code
    {
      Serial.println("left");
      digitalWrite(INA,HIGH);                  // causes car to turn left
      digitalWrite(INB,LOW);
      irrecv.resume();                                             // recieve another input
      delay (200);
      while (results.value == 0xFFFFFFF)    // while the sensor continues to recieve same input........
      {
        digitalWrite(INA,HIGH);                 // continue turning left
        digitalWrite(INB,LOW);
      }
      
    }
    if (results.value == 0xFF48B7)//stop     // if infared recieves the power button code do this code
    {
      Serial.println("stop");
      digitalWrite(PWMA,LOW);               // put motor speed to 0
      digitalWrite(PWMB,LOW);
    }
    if (results.value == 0xFF6897)//start    // if infared recieves the input button code do this code
    {
      Serial.println("start");
      digitalWrite(PWMA,HIGH);                 // put motor speed to 255
      digitalWrite(PWMB,HIGH);
    }
      Serial.println(results.value, HEX);         // show the input values in the serial monitor
      irrecv.resume();                                      // recieve another input
    }
  
  delay(100);
}









Thursday, November 20, 2014

Dane and Warren Final Project

Me and warren are in a group for the final project and we are doing a randomized moving car it will have 4 wheels and four motors and possibly blinking LEDs

Thursday, September 25, 2014

Assignment 5.2

Overall, we had very little problems. However, one problem we had was we switched around two of the insistors which caused the button not to work. We hope to learn from this experience and not do this next time.
Love, Albert and Dane

Friday, September 19, 2014

Pointless Hard Drive Pic


Pointless Hard Drive

/*
 * Drive size calculator!
 */

int drive_gb = 5;
int drive_mb;

void setup()                    // run once, when the sketch starts
{
  Serial.begin(9600);           // set up Serial library at 9600 bps

  Serial.print("Your HD is ");
  Serial.print(drive_gb);
  Serial.println(" GB large.");

  drive_mb = 1024 * drive_gb;

  Serial.print("It can store ");
  Serial.print(drive_mb);
  Serial.println(" Megabytes!");
}

void loop()                 // we need this to be here even though its empty
{

}

For Loop

void setup()
{
    for (int ledPin = 13; ledPin >= 9; ledPin = ledPin-1)
 {  
    pinMode(ledPin, OUTPUT);
 }

}

void loop()
{
  for (int ledPin = 13; ledPin >= 9; ledPin = ledPin-1)

 {  
    digitalWrite(ledPin, HIGH);
 }
delay(100);
 for (int ledPin = 9; ledPin <= 13; ledPin = ledPin+1)
{
    digitalWrite(ledPin, LOW);
   
}

delay(100);
}