Announcements

November 24, 2007
Reading for November 27th, are now posted. Enjoy!

October 2, 2007
To upload your thoughtless acts, create a new assignment page like any other lab. You'll see "Thoughtless Acts" listed as one of the assignment options.

May 24, 2008
This site has been archived and is no longer editable. Stay tuned for the next version, coming in the fall!


Visual Record for DC Motor Speed

Project Members: 
kartikeya

Description:

I chose to build a visual feedback system for the DC Motor output. I used 3 LED's whose blinking indicated the output of the motor. When the motor has upto 1/3rd output, only the green LED blinks slowly. When the motor has 1/3rd to 2/3rd output, the green and blue LED's blink faster than before. When the motor has 2/3rd to full output, all three LED's blink very fast.

Components:

3 LED's - Blue, Green and Red

DC Motor

2 AA Batteries

 

Code:

/*
* one pot fades one motor
* modified version of AnalogInput
* by DojoDave <http://www.0j0.org>
* http://www.arduino.cc/en/Tutorial/AnalogInput
* Modified again by dave
*/

int potPin = 0; // select the input pin for the potentiometer
int motorPin = 9; // select the pin for the Motor
int val = 0; // variable to store the value coming from the sensor
int ledpin1 = 13;
int ledpin2 = 12;
int ledpin3 = 11;
int num = 0;

void setup() {
Serial.begin(9600);
pinMode(ledpin1, OUTPUT);
pinMode(ledpin2, OUTPUT);
pinMode(ledpin3, OUTPUT);
}
void loop() {
val = analogRead(potPin); // read the value from the sensor, between 0 - 1024
Serial.println(val/4);
analogWrite(motorPin, val/4); // analogWrite can be between 0-255
num = val/4;
if (num > 0 and num < 85) {
digitalWrite(ledpin1, HIGH);
delay(1000);
digitalWrite(ledpin1,LOW);
delay(1000);
}
if (num >84 and num <170) {
digitalWrite(ledpin1, HIGH);
digitalWrite(ledpin2, HIGH);
delay(500);
digitalWrite(ledpin1,LOW);
digitalWrite(ledpin2,LOW);
delay(500);
}
if (num >169) {
digitalWrite(ledpin1, HIGH);
digitalWrite(ledpin2, HIGH);
digitalWrite(ledpin3, HIGH);
delay(100);
digitalWrite(ledpin1,LOW);
digitalWrite(ledpin2,LOW);
digitalWrite(ledpin3,LOW);
delay(100);
}

}

Images:

DC Motor Output with LED's

DC Motor Output with LED's

Video Link:



Powered by Drupal - Design by Artinet