/* Motor Speed Control from Varible Resistor * *Christian Nold */ int potPin = 5; // select the input pin for the potentiometer int MotorPin = 10; // this can be pin 9,10 or 11 int val = 0; // variable to store the value coming from the sensor void setup() { beginSerial(9600); pinMode(MotorPin, OUTPUT); // declare the ledPin as an OUTPUT } void loop() { val = analogRead(potPin); // read the value from the sensor printInteger(val); // dedugs the value of the analog sensor serialWrite(10); //newline serialWrite(13); // carriage return analogWrite(MotorPin, val / 4); // send out an "analog" voltage that controls the speed of the motor - the divide by 4 it to keep the number in the 0-255 range }