denny9167
Member level 1
Here is a great function for those into both RF(OOK) or IR(PWM) communication, this function works for motor direction, which is a plus in robotics and other similar automations. Change IR_PIN designation and state depending on application, and also change TimerH value to adjust delay after timeout.
Code:
void Idle(){
uint8_t TimerL = 0;
uint8_t TimerH = 75;
// IR receiver idles with output HIGH , so wait until it goes LOW
// When hold down timer expires all momentary outputs are forced off
while(IR_PIN) {
if(--TimerL == 0) {
if(--TimerH == 0) {
F_momentary = 1;
if(F_momentary) {
// Clear any output when timer expires.
}
}
}
}
}
Last edited: