G2A Many GEOs
SHARE
TWEET

Hier nochmal der Code richtig

a guest Jul 14th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Servo.h>
  2. Servo s;
  3. int servopin = 13;
  4. const int waitTime = 50;
  5.  
  6. int eingang= A0;
  7. int sensorWert = 0;
  8.  
  9. int pos = 90;
  10.  
  11. void setup() {
  12.  
  13. Serial.begin(9600);
  14. s.attach(servopin);
  15. delay(10000);
  16. }
  17.  
  18. void loop() {
  19.  
  20. sensorWert =analogRead(eingang);
  21. Serial.print("Sensorwert = " );
  22. Serial.println(sensorWert);
  23.  
  24. do {
  25.  
  26.  
  27.   for(pos = 90; pos < 150; pos += 1) {  // von 0 bis 180 Grad, in Schritten von einem Grad
  28.     s.write(pos);                   // sagt dem Servomotor, in welche Position sich drehen soll      
  29.     delay(50);
  30.     sensorWert =analogRead(eingang);
  31.     Serial.print("Sensorwert = " );
  32.     Serial.println(sensorWert);
  33.   }
  34.  
  35.   delay(500);
  36.   for(pos = 150; pos > 30; pos -= 1) {  // von 0 bis 180 Grad, in Schritten von einem Grad
  37.     s.write(pos);                   // sagt dem Servomotor, in welche Position sich drehen soll      
  38.     delay(50);
  39.     sensorWert =analogRead(eingang);
  40.     Serial.print("Sensorwert = " );
  41.     Serial.println(sensorWert);
  42.   }
  43.   delay(500);
  44.   for(pos = 30; pos < 90; pos += 1) {  // von 0 bis 180 Grad, in Schritten von einem Grad
  45.     s.write(pos);                   // sagt dem Servomotor, in welche Position sich drehen soll      
  46.     delay(50);
  47.     sensorWert =analogRead(eingang);
  48.     Serial.print("Sensorwert = " );
  49.     Serial.println(sensorWert);
  50.   }
  51.  
  52. } while (sensorWert < 80);
  53.  
  54.  
  55. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top