Monday, 31 October 2011

CIRC-03: Transistors & Motors

Purpose: 
Get the toy motor to spin.

Equipment:
•1 x Arduino Uno
•1 x Breadboard
•6 x Wire
•1 x Toy Motor
•1 x Transistor
•1 x Diode
•1 x 2.2k Ohm Resistor


Reference:
http://www.oomlout.com/a/products/ardx/circ-03


Program Details: 
Same methods as CIRC-01. Motors are initialized the same LEDs are.

Time to Complete: 
10 minutes

Results:
Forgot to upload the program, after uploading, the motor still wasn't spinning. Turns out the positive and negative on the motor was hooked up incorrectly. After fixing the connection, the motor began to spin.

Photos of Project: 

Tips:
Watch out for the pesky positive and negative connections.

Further Work:
We can change the speed or acceleration of the motor.


Program Modifications:
The program is exactly the one from http://www.oomlout.com/a/products/ardx/circ-03

Program:

int motorPin = 9;  // the pin the motor is connected to
                  
void setup()
 {
pinMode(motorPin, OUTPUT); //initalizes pin 9 as an output
 }

void loop()                     // Continuously runs
 {
  motorOnThenOff();             //Calls the function motorOnThenOff
 }


void motorOnThenOff() //creates a void-type function, motorOnThenOff
 {
  int onTime = 2500;  //time(in milliseconds) the motor is set to turn on for
  int offTime = 1000; // time(in milliseconds) the motor is set to turn off for

  digitalWrite(motorPin, HIGH); // changes the state of the pin9 to On
  delay(onTime);                // delay equal to the value of onTime
  digitalWrite(motorPin, LOW);  // changes the state of the pin9 to Off
  delay(offTime);               // delay equal to the value of offTime
 }
}

CIRC-02: Multiple LEDs

Purpose: 
Get 8 LEDs to blink on and off in a sequence.

Equipment:
-8 x LED
-10 x Wires
-8 x 560ohm resistor
-1 x Arduino Uno
-1 x Breadboard

Reference:
http://www.oomlout.com/a/products/ardx/circ-02

Program Details: 
This experiment had included arrays. functions, and for loops in the code. It was fairly simple to pick up since the Arduino language is similar to Java.

Time to Complete: 
20 minutes

Results:
No errors with this experiment, LEDs lit up without a problem.

Photos of Project: 




Tips:
Similar to CIRC-01, just with 8 LEDs this time. Keep your LEDs, resistors, and wires consistently spaced out.

Further Work:
Change the sequence by playing with the order of the on and off lines of code.

Program Modifications:
The program is exactly the one from http://www.oomlout.com/a/products/ardx/circ-02

Program:

//An array that hold the pin each LED is connected to
int ledPins[] = {2,3,4,5,6,7,8,9};

void setup()
{
  for(int i = 0; i < 8; i++)      //loop to initialize each pin as an output
  {  
      pinMode(ledPins[i],OUTPUT); 
  }                                   
 
}
 
 

void loop()                     // Continuously runs
{
  oneAfterAnotherNoLoop();   //calls the function oneAfterAnotherNoLoop 
}
 

void oneAfterAnotherNoLoop()
 {
  int delayTime = 100; //sets a delay time
//turns LEDs on
  digitalWrite(ledPins[0], HIGH);  /*changes state of LED connected to pin 2  to high(on)*/
  delay(delayTime);                //delay equal to the value of delayTime
  digitalWrite(ledPins[1], HIGH);  /*changes state of LED connected to pin 3  to high(on)*/
  delay(delayTime);                //delay equal to the value of delayTime
  digitalWrite(ledPins[2], HIGH);  /*changes state of LED connected to pin 4  to high(on)*/
  delay(delayTime);                //delay equal to the value of delayTime
  digitalWrite(ledPins[3], HIGH);  /*changes state of LED connected to pin 5  to high(on)*/
  delay(delayTime);                //delay equal to the value of delayTime
  digitalWrite(ledPins[4], HIGH);  /*changes state of LED connected to pin 6  to high(on)*/
  delay(delayTime);                //delay equal to the value of delayTime
  digitalWrite(ledPins[5], HIGH);  /*changes state of LED connected to pin 7  to high(on)*/
  delay(delayTime);                //delay equal to the value of delayTime
  digitalWrite(ledPins[6], HIGH);  /*changes state of LED connected to pin 8  to high(on)*/
  delay(delayTime);                ////delay equal to the value of delayTime
  digitalWrite(ledPins[7], HIGH);  /*changes state of LED connected to pin 9  to high(on)*/

  delay(delayTime);                //delay equal to the value of delayTime
 //Turns LEDs off
  digitalWrite(ledPins[7], LOW);  //*changes state of LED connected to pin 2  to high(on)*/
  delay(delayTime);                //delay equal to the value of delayTime
  digitalWrite(ledPins[6], LOW);  //*changes state of LED connected to pin 3  to high(off)*/
  delay(delayTime);                //delay equal to the value of delayTime
  digitalWrite(ledPins[5], LOW);  //*changes state of LED connected to pin 4  to high(off)*/
  delay(delayTime);                //delay equal to the value of delayTime
  digitalWrite(ledPins[4], LOW);  //*changes state of LED connected to pin 5  to high(off)*/
  delay(delayTime);                //delay equal to the value of delayTime
  digitalWrite(ledPins[3], LOW);  //*changes state of LED connected to pin 6  to high(off)*/
  delay(delayTime);                //delay equal to the value of delayTime
  digitalWrite(ledPins[2], LOW);  //*changes state of LED connected to pin 7  to high(off)*/
  delay(delayTime);                //delay equal to the value of delayTime
  digitalWrite(ledPins[1], LOW);  //*changes state of LED connected to pin 8  to high(off)*/
  delay(delayTime);                //delay equal to the value of delayTime
  digitalWrite(ledPins[0], LOW);  //*changes state of LED connected to pin 9  to high(off)*/
  delay(delayTime);                //delay equal to the value of delayTime
 } 

}

CIRC-01: Blinking LED

Purpose: 
Get one LED to blink on and off.

Equipment:

-1 x Arduino Uno
-1 x Breadboard
-3 x Wire

-1 x LED
-1 x 560 Ohm Resistor

Reference:
http://www.oomlout.com/a/products/ardx/circ-01

Program Details: 
This experiment was a little introduction to Arduino. It shows the basic code structure and how it relates to what's happening on hardware.

Time to Complete: 
5 minutes

Results:
The LED lit up with no problems.
Photos of Project: 



Tips:
Straight forward experiment, just make sure that the LED is in the right way (long side is positive).

Further Work:
I can try to make it blink faster or slower by changing the delay.

Program Modifications:
The program is exactly the one from http://www.oomlout.com/a/products/ardx/circ-01

Program:

int ledPin =  13;    // the pin the LED is connected to.
 
// The setup() method runs once, when the sketch starts
 
void setup()  
{                
    pinMode(ledPin, OUTPUT); //initializes pin 13 as an output   
}
 
 
void loop()               //Continuously runs     
{
  digitalWrite(ledPin, HIGH);   // changes the state of ledPin to high(on)
  delay(1000);                  // delay equal to the 1000 millisecons
  digitalWrite(ledPin, LOW);    // changes the state of ledPin to low(off)
  delay(1000);                  // delay equal to the 1000 millisecons
}