Created
February 5, 2019 17:42
-
-
Save codebudo/93a6d7431ebf0a8d2d951dbaddcef012 to your computer and use it in GitHub Desktop.
Sample multiple PWM signals. This is a counterexample. Don't do this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const int CH_1_PIN = 9; | |
| const int CH_2_PIN = 10; | |
| const int CH_3_PIN = 11; | |
| char buf [64]; | |
| void setup() { | |
| Serial.begin(9600); | |
| } | |
| void loop() { | |
| // sample PWM inputs | |
| int ch_1 = pulseIn(CH_1_PIN, HIGH, 25000); // right stick left-right | |
| int ch_2 = pulseIn(CH_2_PIN, HIGH, 25000); // right stick up-down | |
| int ch_3 = pulseIn(CH_3_PIN, HIGH, 25000); // left stick up-down | |
| sprintf(buf, "%3d %3d %3d", ch_1, ch_2, ch_3); | |
| Serial.println(buf); | |
| delay(5); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment