Skip to content

Instantly share code, notes, and snippets.

@sebadima
Last active June 19, 2020 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebadima/a86c9147a14926b8f81687f226736055 to your computer and use it in GitHub Desktop.
Save sebadima/a86c9147a14926b8f81687f226736055 to your computer and use it in GitHub Desktop.
/*
Driver per motore elettrico brushed
Robotdazero - https://www.robotdazero.it
Il circuito:
- pin 9 di Arduino collegato alla base del TIP120
creato 16 Maggio 2018
modificato 18 Febbraio 2020
by sebadima
- This example code is in the public domain.
- Questo programma viene fornito gratuitamente
anche per usi commerciali.
*/
int pinMotorino = 9;
void setup() {
Serial.begin(9600);
pinMode(pinMotorino, OUTPUT);
}
void loop() {
Serial.print("LOOP\n");
// accelerazione progressiva del motore
for(int x = 0; x <= 255; x++){
analogWrite(pinMotorino, x);
delay(10);
}
// rallentamento progressivo
for(int x = 255; x >= 20; x--){
analogWrite(pinMotorino, x);
delay(10);
}
// pausa brevissima introdotto solo per precauzione
delay(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment