DC motor

Posted by yoon

yoon's picture

 

  • Components used

 red and blue LEDs, diffuser made out of tissue, paper fan with DC motor, potentiometer, Arduino board, transistor, diode, resistors and so on.

  •  Description

Fan controlled by the potentiometer cools down the object: it shows the temperature of it - when the fan is off, the object is hot (red) and as fan goes faster and faster, the object is cooled down and becomes more blue.

  • Video available here: 

http://www.youtube.com/watch?v=nh9D24r9jZ0

  • Arduino Code
 
int potPin = 0;   // select the input pin for the potentiometer
int motorPin = 9; // select the pin for the Motor
int red = 5;  //select the pins for LEDs
int blue = 6;
int val = 0;
int x = 0;
 
 
void setup() {
  Serial.begin(9600);
}
void loop() {
  val = analogRead(potPin);   
  x = map(val, 0, 1024, 0, 255);   //maps 0-1024 to 0-255 to use analogWrite
  
  analogWrite(red, 255-x);
  analogWrite(blue, x);
  analogWrite(motorPin, x); 
   Serial.println(x);
  
}
0
Your rating: None
Tags: