Read a slider on the Arduino
FunduinoPublished on
Analoge Werte einlesen und damit eine LED steuern
You need this
10 kOhm Slide Potentiometer - linear, 20 mm travel, up to 12 V
2,90 € *Item no. F23106454About the product — 10 kOhm Slide Potentiometer - linear, 20 mm travel, up to 12 V
Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
11,12 € *Item no. F23107480About the product — Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
830-point Breadboard - solderless breadboard for Arduino
2,90 € *Item no. FUN-1010553About the product — 830-point Breadboard - solderless breadboard for Arduino
Breadboard Cables Male-to-Male - 40 Pieces, 20 cm
1,74 € *Item no. FUN-1010558About the product — Breadboard Cables Male-to-Male - 40 Pieces, 20 cm
All 4 parts together 18,66 € *Ready to ship immediately · Delivery time: 1-3 business days
* All prices include statutory VAT, plus shipping costs.
How a slider works
Build the circuit
The program
Control the blinking speed with the slider
int eingang= A0; // Port A0 is now equated with the word "eingang"
int sensorwert = 0; // "sensorwert" is used as a variable for the slider value
void setup()
{
pinMode (13, OUTPUT); // Pin 13 is set as an output so the LED connected there can be used
Serial.begin (9600); // Start the data connection to the serial monitor
}
void loop()
{
sensorwert =analogRead(eingang); //The slider value is read and stored in the variable "sensorwert"
Serial.println (sensorwert); // The value is sent to the serial monitor
digitalWrite (13, HIGH); // Turn on the LED on pin 13
delay (sensorwert); // LED lights up for the duration of the sensor value (in milliseconds)
digitalWrite (13, LOW); // Turn off the LED on pin 13
delay (sensorwert); // LED stays off for the duration of the sensor value (in milliseconds)
}Rate the instructions