SHARE
TWEET

Untitled

a guest Jul 20th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <debug.h>
  2. #include <makros.h>
  3. #include <RCReceive.h>
  4. #include <StepperControl.h>
  5. #include <CheapStepper.h>
  6. #include <Stepper_28BYJ_48.h>
  7. #include <Stepper.h>
  8.  
  9. // Change this to your PWMPIN ;)
  10. #define PWM_READ_PIN 3
  11.  
  12. // Change these to your MOTOR Pins ;)
  13. #define MOTOR_PIN1 22
  14. #define MOTOR_PIN2 23
  15. #define MOTOR_PIN3 24
  16. #define MOTOR_PIN4 25
  17.  
  18. int SPU = 1024;
  19. Stepper motor(SPU, MOTOR_PIN1, MOTOR_PIN2, MOTOR_PIN3, MOTOR_PIN4);
  20.  
  21. // setup() wird einmal zu Programmbeginn ausgeführt
  22. void setup()
  23. {
  24.   // Setup PWM stuff
  25.   pinMode(PWM_READ_PIN, INPUT);
  26.  
  27.   // Setup stepper
  28.   motor.setSpeed(2);
  29.  
  30.   // Serielle Kommunikation starten
  31.   Serial.begin(9600);
  32. }
  33.  
  34. // loop() wird endlos wiederholt
  35. void loop()
  36. {
  37.   // Read PWM stuff
  38.   int v = pulseIn(PWM_READ_PIN, HIGH, 25000);
  39.  
  40.   // links:    850
  41.   // neutral: 1460
  42.   // rechts:  2015
  43.   int neutral = 1460;
  44.   int puffer = 100;
  45.   int steps = 10;
  46.   if ( v < ( neutral-puffer ) )
  47.   {
  48.      motor.step( steps );
  49.   }
  50.   if ( v > ( neutral+puffer ) )
  51.   {
  52.      motor.step( -steps );
  53.   }
  54.  
  55.   // Kurze Pause, damit der Servo die neue Position anfahren kann
  56.   delay(50);
  57. }
RAW Paste Data
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