Bez popisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PPM-PWM-Servo.ino 686B

123456789101112131415161718192021222324
  1. #include <PPM.h>
  2. #include <Servo.h>
  3. #define SERVO_PIN 9 // servo signal pin
  4. #define CHANNELS 8 // max ppm channels
  5. #define PPM_PIN 2 // receiver ppm pin
  6. #define LED 5 // led pin
  7. Servo servo;
  8. void setup() {
  9. ppm.begin(PPM_PIN, CHANNELS);
  10. servo.attach(SERVO_PIN);
  11. pinMode(LED, OUTPUT);
  12. Serial.begin(115200);
  13. }
  14. void loop() {
  15. //servo.writeMicroseconds(ppm.getServo_us(1)); // write in range from (544 - 2400)us -> (0 - 180)deg. This is much faster than servo.write(0 - 180)
  16. servo.writeMicroseconds(ppm.get(1)); // write raw PPM value to servo (1000 - 2000)us
  17. analogWrite(LED, ppm.getPWM(3)); // write PWM value from channel 3 to led
  18. }