Synthetech
(Synthetech)
November 13, 2014, 8:06pm
1
PWM/analog input?
Hey all. Great support here
Does anyone know of sketches that allow inputs from PWM signal?
I’m using 5v PWM signals from a hobby aircraft radio control receiver.
Should I just treat the input as a regular 0-5v ADC?
What I want to do is control speeds of flashing/animations, colors/pattern selections, etc.
Eventually I want it to respond to at least 3 channels-
Throttle
Pitch
Roll
Thanks in advance!
~Blaine
Tod_Kurt
(Tod Kurt)
November 13, 2014, 8:52pm
2
You can use the standard Arduino function “pulseIn()” to read the width of servo pulses from your receiver. http://arduino.cc/en/Reference/pulseIn
Synthetech
(Synthetech)
November 13, 2014, 9:01pm
3
Thanks Tod.
So I guess it’s a matter of finding out what range of pulse timing my Rx sends out and use it’s values to alter light patterns?
Tod_Kurt
(Tod Kurt)
November 13, 2014, 9:26pm
4
Exactly. Servo pulses typically range between 1000 microseconds and 2000 microseconds, with 1500 microseconds being considered middle/neutral.
So you can do something like:
void loop() {
unsigned long duration = pulseIn(receiverPin, HIGH);
if( duration > 1700 ) { // stick pushed up
leds[0] = CRGB::Green;
}
else if( duration < 1300 ) { // stick pushed down
leds[0] = CRGB::Red;
}
else { // stick in the middle
leds[0] = CRGB::Yellow;
}
FastLED.show();
}
Synthetech
(Synthetech)
November 13, 2014, 10:10pm
5
I’m revisiting how arduino code works…
so “unsigned long” is the type of variable “duration” is?
pulseIn is the source of the data from a RxPin to assign to the variable?
then we use “duration” to compare in the if/else statements?
Synthetech
(Synthetech)
November 15, 2014, 4:48pm
7
thanks for the help.
looks like I have a lot of reading to do to figure this all out…
Synthetech,
Lemme know if you need help on the hardware side. New engines for interactive art is my passion!!
Steve French
Voltvision.com
Synthetech
(Synthetech)
November 16, 2014, 11:58pm
9
I’ll be getting a 60 led tape w/ 2811’s on it soon to start working with and a Uno to try code on… maybe a nano too.