This is post is about the arduino 4 relay control module which control using the 433 MHz remote control module and receiver. Or how to connect the RF 433mHZ with arduino for remote controlling or debounce system. In this post I am going to share the complete sketch code is used for controlling debounce led or relay.
The below is complete sketch code for debounce. Just copy and paste. Verify the code and click on upload. You can change the setting or do changing in code according your needs.
Watch the video for complete understanding.
I hope after watch the video, now you able to connect the wireless remote control (433MHZ) to arduino. Now if you have any question then use the below comment section.
The below is complete sketch code for debounce. Just copy and paste. Verify the code and click on upload. You can change the setting or do changing in code according your needs.
The above arduino code is for switch on off the leds using button. However we use the 433MHz Wireless Remote Control Switch Module Transceiver Receiver Transmitter DC 2.5V-5.0V with arduino to switch on/off the relay and relay control the light bulb, ceiling fan, socket etc in room wiring.// set pin numbers:const int buttonPin = 2; // the number of the pushbutton pinconst int ledPin = 12; // the number of the LED pinconst int buttonPin2 = 3; // the number of the pushbutton pinconst int ledPin2 = 11; // the number of the LED pinconst int buttonPin3 = 4;const int ledPin3 = 10;const int buttonPin4 = 5;const int ledPin4 = 9;// Variables will change:int ledState = HIGH; // the current state of the output pinint buttonState; // the current reading from the input pinint lastButtonState = LOW; // the previous reading from the input pinint ledState2 = HIGH; // the current state of the output pinint buttonState2; // the current reading from the input pinint lastButtonState2 = LOW; // the previous reading from the input pinint ledState3 = HIGH;int buttonState3;int lastButtonState3 = LOW;int ledState4 = HIGH;int buttonState4;int lastButtonState4 = LOW;// the following variables are long's because the time, measured in miliseconds,// will quickly become a bigger number than can be stored in an int.long lastDebounceTime = 0; // the last time the output pin was toggledlong debounceDelay = 50; // the debounce time; increase if the output flickerslong lastDebounceTime2 = 0; // the last time the output pin was toggledlong debounceDelay2 = 50; // the debounce time; increase if the output flickerslong lastDebounceTime3 = 0;long debounceDelay3 = 50;long lastDebounceTime4 = 0;long debounceDelay4 = 50;void setup() {pinMode(buttonPin, INPUT);pinMode(ledPin, OUTPUT);pinMode(buttonPin2, INPUT);pinMode(ledPin2, OUTPUT);pinMode(buttonPin3, INPUT);pinMode(ledPin3, OUTPUT);pinMode(buttonPin4, INPUT);pinMode(ledPin4, OUTPUT);// set initial LED statedigitalWrite(ledPin, ledState);digitalWrite(ledPin2, ledState2);digitalWrite(ledPin3, ledState3);digitalWrite(ledPin4, ledState4);}void loop() {// read the state of the switch into a local variable:int reading = digitalRead(buttonPin);int reading2 = digitalRead(buttonPin2);int reading3 = digitalRead(buttonPin3);int reading4 = digitalRead(buttonPin4);// check to see if you just pressed the button// (i.e. the input went from LOW to HIGH), and you've waited// long enough since the last press to ignore any noise:// If the switch changed, due to noise or pressing:if (reading != lastButtonState) {// reset the debouncing timerlastDebounceTime = millis();}if (reading2 != lastButtonState2) {// reset the debouncing timerlastDebounceTime2 = millis();}if (reading3 != lastButtonState3) {// reset the debouncing timerlastDebounceTime3 = millis();}if (reading4 != lastButtonState4) {// reset the debouncing timerlastDebounceTime4 = millis();}if ((millis() - lastDebounceTime) > debounceDelay) {if ((millis() - lastDebounceTime2) > debounceDelay2) {if ((millis() - lastDebounceTime3) > debounceDelay3) {if ((millis() - lastDebounceTime4) > debounceDelay4) {// whatever the reading is at, it's been there for longer// than the debounce delay, so take it as the actual current state:// if the button state has changed:if (reading != buttonState) {buttonState = reading;// only toggle the LED if the new button state is HIGHif (buttonState == HIGH) {ledState = !ledState;}}}if (reading2 != buttonState2) {buttonState2 = reading2;// only toggle the LED if the new button state is HIGHif (buttonState2 == HIGH) {ledState2 = !ledState2;}}}if (reading3 != buttonState3) {buttonState3 = reading3;// only toggle the LED if the new button state is HIGHif (buttonState3 == HIGH) {ledState3 = !ledState3;}}}if (reading4 != buttonState4) {buttonState4 = reading4;// only toggle the LED if the new button state is HIGHif (buttonState4 == HIGH) {ledState4 = !ledState4;}}}// set the LED:digitalWrite(ledPin, ledState);digitalWrite(ledPin2, ledState2);digitalWrite(ledPin3, ledState3);digitalWrite(ledPin4, ledState4);// save the reading. Next time through the loop,// it'll be the lastButtonState:lastButtonState = reading;lastButtonState2 = reading2;lastButtonState3 = reading3;lastButtonState4 = reading4;}
Watch the video for complete understanding.
I hope after watch the video, now you able to connect the wireless remote control (433MHZ) to arduino. Now if you have any question then use the below comment section.
There is no library
ReplyDeleteSalam brother you can send me the code with the library please may Allah five you succès
ReplyDeleteThanks for the blog filled with so many information. Stopping by your blog helped me to get what I was looking for. Now my task has become as easy as ABC. DVD Card Board Type HD Receiver Software Update
ReplyDeleteI found the PERFECT online rental service with a HUGE video library that includes over 72,000 titles. With new releases being added everyday you will have access to the hottest new movies before anyone else. moviesonline4k
ReplyDeleteI have connected every pin in a way you showed but code does not work , please guide.
ReplyDelete