Program
/ * Analog input * /
int potPin = 5; // Selects the input PIN to put the potentiometer
int val = 0; // variable to store the value read from the analog input
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(potPin); // Reads the value from the input analog channel
Serial.print(val); // Sends to the PC the read analog value and displays it
on screen
Serial.write(10);
delay(100);
}
6. DC motor control using a transistor
With this example we are going to control the speed of a DC motor using a
BD137 transistor. Uses the possibility of sending a PWM signal to one of the
outputs set up as analog.
18
18