Home Cinema

I try to reconstruct the first animations using the pot to control the speed (frames/sec) and the motor to control the motion

Parts:

DC motor

Arduino

POT

diode

transistor

 

CODE

/*
 * one pot fades one motor
 * modified version of AnalogInput
 * by DojoDave <http://www.0j0.org>
 * http://www.arduino.cc/en/Tutorial/AnalogInput
 * Modified again by dave  Modified to control the speed
*/

int potPin = 0;   // select the input pin for the potentiometer
int motorPin = 9; // select the pin for the Motor
int newval = 0;
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
  newval = map (val, 0, 1024, 0, 60);
  Serial.println(val);
  analogWrite(motorPin, newval); // analogWrite can be between 0-255
}

 

 

 

photo-14.jpg
0
Your rating: None