Lab 6: Playing with DC motors

Posted by wk

wk's picture

 

Lab 6: Playing with DC motors
 
Description:
In this lab we create a circuit using a DC motor and explore the possibilities of output.
 
I began with the concept of creating an animation sequence.  There were issues with attaching the cardboard creation to the spinning motor.  One of the issues was keeping the creation attached, another was issue was keeping the attachment spinning.
 
So I switched it up and created a little cardboard platform that would spin and create different patterns based on how fast it was spinning.
 
My final creation was a metaphor.  I wanted to know how many people it takes to screw in a lightbulb.  Watch the video to find out.  I used a light sensor for one instance (http://www.youtube.com/watch?v=jdya-BvpG2I), and a potentiometer for another instance (http://www.youtube.com/watch?v=imj3Prs-lFI).
 
Light Sensor:
Pot:
Components:
Arduino Micro-controller
Resistors
Wires
Bread board
Potentiometer
FSR
Transistor
Diode
DC Motor
Paper drawing of a lightbulb
 
Arduino Code:
/*
 * one pot fades one motor
 * switch the comment tags to control the motor with the light sensor
 * modified version of AnalogInput
 * by DojoDave <http://www.0j0.org>
 * http://www.arduino.cc/en/Tutorial/AnalogInput
 * Modified again by dave
 */
 
int sensorPin = 2;   // select the input pin for the light sensor
 
int potPin = 0;   // select the input pin for the potentiometer
int motorPin = 9; // select the pin for the Motor
int val = 0;      // variable to store the value coming from the sensor
void setup() {
  Serial.begin(9600);
}
void loop() {
  val = analogRead(potPin);    // read the value from the sensor, between 0 - 1024
//  val = analogRead(sensorPin); // read the value of the light sensor
  Serial.println(val);
  analogWrite(motorPin, val/4); // analogWrite can be between 0-255
}
 
 
0
Your rating: None
Tags: