Description
Arduino Force Sensitive DC Motor Fan
For this lab, I imagined how hot my roommate keeps the temperature in the room, making for sleepless nights. I created a fan that turns on when you go to sleep (when you lay your head down on a pillow). The fan speed is controlled with a potentiometer.
A Force Sensitive Resistor (FSR) is connected to Arduino input pin 1 (A1).
A potentiometer receives 5V from the Arduino processor, its output connected to pin 0 (A0), with bleed-off going through a 10K Ω resistor to ground. This output voltage is connected to the base of a transistor through pin ~9, which acts as a switch. When power is present, and IF the FSR has more than the limit voltage, the switch turns on. Power then goes through a battery pack through a DC motor (which has a diode in parallel to prevent backward current flow through the motor) to ground. A fan blade is connected to the motor to allow it provide cool air while spinning.
The fan can be placed in a convenient location to cool someone who places his or her head on a pillow with the FSR underneath.
Components Used
1- Arduino Board
1 – 10K Ω Resistor (between FSR and ground)
1 – 1 Ω Resistor (between transistor base and ground)
1 – Force Sensitive Resistor (FSR)
1 – DC Motor
1– 3V Battery Pack
1– Breadboard
1 – Diode (1N4004)
Connecting wires
Code
/*
* Motor (with fan blade attached) controled by FSR, laid under a pillow
* Potentiometer controls speed
* modified version of AnalogInput
* by Clint Anderson <clintanderson@berkeley.edu>
*/
int potPin = 0; // select the input pin for the potentiometer (A0)
int fsrPin = 1; // select the input pin for Force Sensitive Resistor (A1)
int motorPin = 9; // select the pin for the Motor (~9)
int potValue = 0; // variable to store the value coming from the sensor
int fsrValue = 0;
bool pillowPressed = false;
void setup() {
Serial.begin(9600);
}
void loop() {
potValue = analogRead(potPin); // read the value from the sensor, between 0 - 1024
fsrValue = analogRead(fsrPin);
Serial.print(potValue);
Serial.print("\t");
Serial.println(fsrValue);
// Only spin the fan if the pillow is being laid on
if (fsrValue > 20){
pillowPressed = true;
}
else{
pillowPressed = false;
}
if (pillowPressed)
analogWrite(motorPin, potValue/4); // analogWrite can be between 0-255
else
analogWrite(motorPin, 0);
}
- Login to post comments