X-Git-Url: http://git.piffa.net/web?a=blobdiff_plain;f=motors%2Fsimple_motor_PWM_potenziometer__minimum_transistor_diode_3%2Fsimple_motor_PWM_potenziometer__minimum_transistor_diode_3.ino;h=d73ec6f3bebae10c3065826822ffb60d041db23d;hb=fbdb4b8b83bbf79d73770f4d8a3e4170511ba6e7;hp=83965d143790493f98bd973d2cc4eaa9d35bfff9;hpb=5b737b67e45cd2ad8243f968667f75cbcc6cab63;p=sketchbook_andrea diff --git a/motors/simple_motor_PWM_potenziometer__minimum_transistor_diode_3/simple_motor_PWM_potenziometer__minimum_transistor_diode_3.ino b/motors/simple_motor_PWM_potenziometer__minimum_transistor_diode_3/simple_motor_PWM_potenziometer__minimum_transistor_diode_3.ino index 83965d1..d73ec6f 100644 --- a/motors/simple_motor_PWM_potenziometer__minimum_transistor_diode_3/simple_motor_PWM_potenziometer__minimum_transistor_diode_3.ino +++ b/motors/simple_motor_PWM_potenziometer__minimum_transistor_diode_3/simple_motor_PWM_potenziometer__minimum_transistor_diode_3.ino @@ -1,24 +1,22 @@ /* - Simple Motor with variable spped from pot input + Simple Motor : Potenziometro con minimo + + Motore DC con variazione della velocita' impostata + tramite un potenziometro 10k ohms, + settato un valore minimo sotto il quale il motore + non viene attivato. + + Schema: http://lab.piffa.net/schemi/motor_pot_bb.png - This sketch use a transistor and a diode - in order to poer a 5v ~150mAh directly from the board. - Hard thing is to find a suitable motor! - - - This version uses a pot as throttle control, - serial for debuggin. - - Optimized for a minimum throttle value in order to keep the motor off */ -const int analogInPin = A0; +const int analogInPin = A0; // Pin a cui e' collegato il potenziometro const int motorPin = 9; int potValue = 0; int motValue = 0; -const int minMotValue = 50 ; // Minimum power requiement of my own motr, - // This is going to differ from motor to motor +const int minMotValue = 50 ; // Valore minimo per il motore, + // questo variera' in base ai motori void setup() { pinMode(motorPin, OUTPUT); @@ -27,10 +25,10 @@ void setup() { } void loop() { potValue = analogRead(analogInPin); - motValue = potValue / 4 ; // Simple mapping 1024 -> 255 + motValue = potValue / 4 ; // mappatura 1024 -> 255 if (motValue > minMotValue) { // Minimum motor spped check - analogWrite(motorPin,motValue); // Change the PWM speed of the motor + analogWrite(motorPin,motValue); // Imposta la velocita' del motore } else { analogWrite(motorPin,LOW) ; } @@ -38,10 +36,10 @@ analogWrite(motorPin,LOW) ; Serial.print("Pot value = " ); Serial.print(potValue); - Serial.print("\t Motor speed = "); + Serial.print("\t Motore velocita' = "); Serial.println(motValue); - delay(3); // Pause, helps to stabilize the input, - // slows the serial output + delay(3); // Pausa, aiuta a stabilizzare l'input + }