Potentiometer mit dem Arduino programmieren: Unterschied zwischen den Versionen
Zeile 2: | Zeile 2: | ||
= Potentiometer angeschlossen im Video = | = Potentiometer angeschlossen im Video = | ||
− | {{#ev:youtube|https://youtu.be/ | + | {{#ev:youtube|https://youtu.be/tgedunWuI18|800}} |
+ | == Der Code dazu == | ||
+ | <pre> | ||
+ | void setup() { | ||
+ | // put your setup code here, to run once: | ||
+ | pinMode(A0, INPUT); | ||
+ | Serial.begin(9600); | ||
+ | |||
+ | pinMode(10, OUTPUT); | ||
+ | digitalWrite(10, LOW); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // put your main code here, to run repeatedly: | ||
+ | Serial.println( analogRead(A0) ); | ||
+ | |||
+ | if(analogRead(A0) <700) { | ||
+ | digitalWrite(10, LOW); | ||
+ | } else { | ||
+ | digitalWrite(10, HIGH); | ||
+ | } | ||
+ | |||
+ | delay(500); | ||
+ | } | ||
+ | </pre> |
Aktuelle Version vom 24. August 2020, 13:04 Uhr
Potentiometer angeschlossen im Video
Der Code dazu
void setup() { // put your setup code here, to run once: pinMode(A0, INPUT); Serial.begin(9600); pinMode(10, OUTPUT); digitalWrite(10, LOW); } void loop() { // put your main code here, to run repeatedly: Serial.println( analogRead(A0) ); if(analogRead(A0) <700) { digitalWrite(10, LOW); } else { digitalWrite(10, HIGH); } delay(500); }