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!


Lab6

Project Members: 
Eun Kyoung Choe

Description

I used one potentiometer to control 2 LEDs and one DC motor.
When you run the program and revolve the potentiometer above the certain threshold (512), the Bear's eyes glow. When you revolve the potentiometer more, the pinwheel whirls.

 

Hardware Components Used

2 LED
3 Resistors (1K*1, 220k*2)
1 Potentiometers
1 DC motor
1 Transistor
1 Diode
Arduino Board
Breadboard
Wires
1 Pinwheel

 

Arduino 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
* Modified again by EunKyoung Choe
* TUI Lab6 Homework
* 10/10/07
*/

int potPin = 0; // select the input pin for the potentiometer
int motorPin = 9; // select the pin for the Motor
int LEDpin1 = 11;
int LEDpin2 = 12;
int threshold1 = 512;
int threshold2 = 900;
int val = 0; // variable to store the value coming from the sensor

void setup() {
Serial.begin(9600);
pinMode(LEDpin1, OUTPUT);
pinMode(LEDpin2, OUTPUT);
}
void loop() {
val = analogRead(potPin); // read the value from the sensor, between 0 - 1024
Serial.println(val);

//if value greater than threshold1 then turn on LED
if (val < threshold1){
digitalWrite(LEDpin1, LOW);
digitalWrite(LEDpin2, LOW);
}

else if (threshold1 < val < threshold2){
digitalWrite(LEDpin1, HIGH);
digitalWrite(LEDpin2, HIGH);
}

//if value greater than threshold2 then turn on motor
else{
digitalWrite(LEDpin1, HIGH);
digitalWrite(LEDpin2, HIGH);
analogWrite(motorPin, val/4); // analogWrite can be between 0-255
}

delay(10);
}

 

Photo

bear


Comments

Comments from TAs

Scary bear! It would be a great starting point to bring to the Halloween party this Tuesday. :) Although it's okay to build things that are just "cool", I'd like to see a little more description of the usage scenario for your project. E.g., why is the bear lighting up and spinning a pinwheel? What type of sensor input might it react to?, etc.?


Powered by Drupal - Design by Artinet