Light controlled fan

Assignment: DC Motor: Actuation Assignment 1

Collaborators:

 

Our task was to explore motion as an output, via the use of a direct current (DC) motor. I have created a fan powered by the motor with the added capability of scaling its speed based on light conditions. This is accomplished by replacing the potentiometer in the original lab with a photocell and having its voltage changes converted into values I use to control the motor motion.

The concept is that the fan could be running at full speed during the day (while the photocell is exposed to sunlight) while slowing down at night or in overcast conditions when less light is detected. Perhaps a temperature-based input would be more appropriate, but the photocell was the closest sensor available.

The code was largely unmodified:

// Set input/output pins
int analogIN = 0;
int motorOUT = 9;

// Variable to hold analog value
int powerVal = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  powerVal = analogRead(analogIN);
  Serial.println(powerVal);
  
  // Scale it down for the motor (0-255)
  analogWrite(motorOUT, powerVal/4);
}