]> git.piffa.net Git - sketchbook_andrea/blob - motors/simple_motor_transistor_diode_0/simple_motor_transistor_diode_0.ino
5b86a2bf7250152e875423bcaa4812d108c4c251
[sketchbook_andrea] / motors / simple_motor_transistor_diode_0 / simple_motor_transistor_diode_0.ino
1 /* Simple Motor
2  This sketch use a transistor and a diode
3  in order to power a 5v ~150mAh directly from the board.
4  Hard thing is to find a suitable motor!
5
6  In order to power a more powerfull motor you need to connect
7  the transistor to an other power line. 
8  */
9
10 int motorPin = 9;
11 void setup() {
12   pinMode(motorPin, OUTPUT); // We drive the motor just like a LED
13 }
14
15 void loop() {
16   digitalWrite(motorPin, HIGH); // Turn on the motor full throttle
17   delay(1000);
18   digitalWrite(motorPin, LOW);  // Turn off motor
19   delay(5000);
20 }
21
22
23