2 Simple Motor with variable spped from pot input
4 This sketch use a transistor and a diode
5 in order to poer a 5v ~150mAh directly from the board.
6 Hard thing is to find a suitable motor!
8 This version uses a pot as throttle control,
12 const int analogInPin = A0;
13 const int motorPin = 9;
19 pinMode(motorPin, OUTPUT);
20 Serial.begin(9600); // Debuggin
24 potValue = analogRead(analogInPin);
25 motValue = potValue / 4 ; // Simple mapping 1024 -> 255
27 analogWrite(motorPin,motValue); // Change the PWM speed of the motor
29 Serial.print("Pot value = " );
30 Serial.print(potValue);
31 Serial.print("\t Motor speed = ");
32 Serial.println(motValue);
33 delay(3); // Pause, helps to stabilize the input
34 // and keeps a brushed motor from over heating ;)