/* motor-poti-tip120.ino * * Steuerung eines Elektromotors über Fremdspannung * mittels TIP 120 und einem Poti mit 470 kOhm * * Download: https://www.brixelweb.de */ int potianschluss = A1; int motorpin = 5; int potiwert = 0; int ausgabe = 0; void setup() { Serial.begin(9600); Serial.println(" Auslesen eines Potis: "); Serial.println("---------------------------"); delay(2000); pinMode(5, OUTPUT); } void loop() { potiwert = analogRead(potianschluss); ausgabe = map(potiwert, 0, 1023, 0, 255); Serial.print("Poti-Wert: "); Serial.print(potiwert); Serial.print(" - "); Serial.print("Ausgabe-Wert: "); Serial.println(ausgabe); Serial.println("---------------------------"); delay(10); // kurze Pause zum Datenverarbeiten // und Zeit zum Lesen lassen! analogWrite(motorpin, ausgabe); delay(100); }