2020/07/12

Arduino Uno R3 As PWM Switch

Using Arduino Uno R3 to receive RC receiver PWM signal and turn on/off switch to control any appliance. Depending on the channels on the RC receiver used, one controller can control many appliances.

Sketch

#define pwmIn 3 // connect RC receiver signal output to Arduino Uno D3
#define onOffValue 1700 // pwm value to turn on/off switch

int data1;

void setup () {
   pinMode (pwmIn, INPUT);
   pinMode (13, OUTPUT);
 }

void loop () {
   data1 = pulseIn(pwmIn, HIGH);
   if (data1> onOffValue) {digitalWrite (13, HIGH);} else {digitalWrite (13, LOW);}
delay (10);
 }

No comments:

Post a Comment