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);
 }

Arduino Uno R3 Displaying RC Receiver PWM Signal Output

Connecting RC Receiver channel signal output to Arduino Uno R3 D3, compiling, uploading the sketch and displaying the pwm value in Serial Monitor.

Sketch

#define pwmIn 3 // connect RC receiver signal output to Arduino Uno D3

int signal;

void setup() {
   pinMode(pwmIn,INPUT);
   Serial.begin(115200);
}

void loop() {
   signal = pulseIn(pwmIn,HIGH);
   Serial.println(signal);
   delay(10);
}