Assignment: DC Motor: Actuation Assignment 1
Collaborators:
Description:
A DC motor sits under a turntable with a round drawing surface. When a pen is pressed against the turntable's surface, a photocell nearby occludes, activating the rotational motion of the turntable. A Potentiometer controls the rotational speed of the turntable.
Components List:
Notes:
The biggest challenge in creating this project was stuffing into the project enclosure. I decided to do away with the usual project breadboard and use half of a smaller, thin breadboard that I had laying around in my toolbox.
Apologies:
I sincerely apologize for using the RATT song "Round and Round" as the background music for my project video. I acknowledge that it is truly a horrible, horrible song. Maybe the worst song ever made.
Code used in this Assignment:
/* * PhotoSpiroGraph Code * Uses 2 analog inputs * */ int potPin = 0; // select the input pin for the potentiometer int photoPin = 1; // select the input pin for the photocell int motorPin = 9; // select the pin for the Motor int potVal = 0; // variable to store the value coming from the pot int photoVal = 0; // variable to store value coming from the photocell void setup() { Serial.begin(9600); } void loop() { potVal = analogRead(potPin); // read the value from the sensor, between 0 - 1024 photoVal = analogRead(photoPin); // read the value from the sensor, between 0 - 1024 Serial.print("PhotoCell: "); Serial.println(photoVal); Serial.print("Pot: "); Serial.println(potVal); Serial.println("-------------------"); if (photoVal < 45) { // If photocell gets occluded, then spin the turntable!!! analogWrite(motorPin, potVal/4); Serial.println("draw!"); } else { analogWrite(motorPin, 0); // else, don't spin at all! } }