Using Arduino Turn AC bulb with push button On and OFF toggle with relay

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 มิ.ย. 2024
  • This video shows how to turn an AC bulb with push button in Arduino. When you push the button, the bulb goes ON and stays ON, then when you push the button again, the bulb goes OFF and stays off.
    On the page where code is provided, I have included code to use two push buttons to control 2 relay to turn ON/OFF two AC bulbs.
    *** Free Course ***
    Arduino Step by Step Course (over 100 lectures) Starts here • Lesson 00 What is Ardu...
    *** I mentioned in the video that we don't need resistor or LED as this video is about relay. But if you want to turn ON the LED, the resistor used is680Ω but you can use 300Ω to 1000Ω.
    ** Purchase Arduino Start Kit **
    Amazon USA: amzn.to/3z88F9G or just UNO board amzn.to/3aY7KOL
    Amazon Canada: amzn.to/31an88J or just UNO board amzn.to/3pYxSNN
    Amazon Europe (all Europe): amzn.to/3pMCHge or Just UNO board amzn.to/2PgGItD
    AliExpress: s.click.aliexpress.com/e/_9uc7Xe
    Banggood: www.banggood.com/custlink/3GD... or UNO board www.banggood.com/custlink/vKm...
    eBay: ebay.us/B1JWLi
    ***** Purchase Authentic Arduino Uno from ***
    Amazon USA: amzn.to/2KApAwK
    Amazon Canada: amzn.to/37LZ8sW
    All Europe Amazon: amzn.to/36YDSzn
    I will reply to all Subscriber's 🔔 questions. So make sure to Subscribe.😊
    Please like 👍 the video and type simple word in the comment. It helps me a lot.
    Jump to different chapters of this video
    00:00 Start
    00:55 Introduction
    03:13 AC Bulb wiring
    03:58 Wiring Arduino
    06:32 Wiring Diagram and Code
    11:12 Demonstration
    Download code for this video: robojax.com/L/?id=172
    Turn ON and OFF LED (when release button LED OFF) • Arduino for Beginners:...
    ***** Purchase Authentic Arduino Uno from ***
    Amazon USA: amzn.to/2KApAwK
    Amazon Canada: amzn.to/37LZ8sW
    Amazon Europe (all Europe): amzn.to/3bKOMug
    *** Purchase Arduino Uno Compatible
    Amazon USA: amzn.to/3aY7KOL
    Amazon Canada: amzn.to/3pYxSNN
    Amazon Europe (all Europe): amzn.to/2PgGItD
    ********Purchase item *****
    Relay from Amazon : amzn.to/3p1n0iL
    Push buttons from Amazon: amzn.to/3eFlwWN
    Using 4 Push button push-ON and push-OFF 4 relays with Arduino:
    • Home Automation: Using...
    How to use Breadboard: • How to use breadboard?...
    Tutorial by Ahmad Shamshiri form Canada
    ****************************
    Arduino Step by Step Course (over 100 lectures) Starts here • Lesson 00 What is Ardu...
    Learn Arduino in 30 Minutes (video): robojax.com/L/?id=135
    ****************************
    If you found this tutorial helpful, please support me so I can continue creating contents like this. Here is PayPal link paypal.me/robojaxTV
    If you want to learn Arduino from proven instructor on **Udemy**: bit.ly/rj-udemy
    Follow me on Facebook robojaxTV
    Follow me on Twitter: / robojaxtv
    Follow me on Instagram: / robojax
    Tutorial by Robojax.com
    Get other projects code and learn Arduino
    robojax.com/learn/arduino
    #robojax #robojaxRelay #robojaxPushButton
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 232

  • @penenadpi
    @penenadpi 4 ปีที่แล้ว +2

    Very useful for my current IoT-based smart grid project.

    • @robojax
      @robojax  4 ปีที่แล้ว

      Thank you. Good to hear that.

  • @DTurvold
    @DTurvold 3 ปีที่แล้ว +1

    Thank you! Very nice video.

  • @heaven4261
    @heaven4261 5 ปีที่แล้ว +1

    It's so cool.
    It has been a great help

    • @robojax
      @robojax  5 ปีที่แล้ว +1

      Good to hear that. Thanks

  • @Ducerobot
    @Ducerobot 11 หลายเดือนก่อน

    Another cool video 😁

  • @ibing02
    @ibing02 5 ปีที่แล้ว

    very helpful!!! thanks a lot!

    • @robojax
      @robojax  5 ปีที่แล้ว

      You are welcome.

  • @bartbonnyns
    @bartbonnyns 4 ปีที่แล้ว +1

    Hello Robojax,
    Thnx a lot for your great TH-cam, It means a lot if you share what you’re good in, so we can learn from each other. I hope you have time for a small simple question. Is there power on your relay coil when the NO contact is closed (when you’re hooked up appliance is on) like a standard relay or does it gets a pulse each time you switch on and off you’re appliance?
    Greats
    Bart

    • @robojax
      @robojax  4 ปีที่แล้ว +1

      Hi, you are welcome. here is my video on relay th-cam.com/video/N-fFk51Eb8s/w-d-xo.html

  • @sushildamle3449
    @sushildamle3449 2 ปีที่แล้ว

    In case I have 3 switches and 3 appliances (say bulb, fan, night lamp), can I simply copy the code three times by using appropriate nomenclature?

  • @silonian1
    @silonian1 6 หลายเดือนก่อน +1

    Thank you so much sir, I used your code and made a few changes, basically you saved my time because I successfully completed my Arduino Code, without this video, I will still be struggling.

    • @robojax
      @robojax  6 หลายเดือนก่อน

      Glad I could help!

  • @chameeraabhishek2969
    @chameeraabhishek2969 ปีที่แล้ว

    Very useful ,thanks

  • @JasonDeLorenzo
    @JasonDeLorenzo 4 ปีที่แล้ว +1

    Thank you for making such a great video! I have one question. How can I make it to where I can hold the button down to turn on relay and release will turn it off?

    • @robojax
      @robojax  4 ปีที่แล้ว +1

      You are welcome. Here is the simple form. You can use Relay instead of LED in this video th-cam.com/video/2WwedCRwmgA/w-d-xo.html

    • @abrouguihelmi4789
      @abrouguihelmi4789 4 ปีที่แล้ว +1

      Robojax q

  • @kenneth123skate321
    @kenneth123skate321 2 ปีที่แล้ว +1

    thank, very useful for mee, thanks !!!

    • @robojax
      @robojax  2 ปีที่แล้ว

      You are welcome. Here is $200 Arduino course for free Arduino Step by Step Course (over 100 lectures) Starts here robojax.com/L/?id=338

  • @yashwanthbabudasari1335
    @yashwanthbabudasari1335 6 ปีที่แล้ว

    Thank you so much this is stuff I need :)

    • @robojax
      @robojax  6 ปีที่แล้ว

      You are welcome.

    • @yashwanthbabudasari1335
      @yashwanthbabudasari1335 6 ปีที่แล้ว

      Bro, actually I need your help can you help me please . if you are willing to do please reply me to this mail (dasari17144@iiitd.ac.in) I need your help in fixing the push button with a battery and that push button in connected to ardunio please mail me if you are willing to do. I can tell me clearly ..

  • @nawinlifehacks9978
    @nawinlifehacks9978 5 ปีที่แล้ว +3

    nice video sir...and also please make operating relay with manual switch operating and mobile operating{wirless operating).iam already told you in last video,

    • @robojax
      @robojax  5 ปีที่แล้ว

      Your request has low priority. Out of over 200,000 views in a month in my channel, only 500 might be interested in mobile. I will do it when I get time for it.

  • @TheWindtalker2011
    @TheWindtalker2011 3 ปีที่แล้ว

    hi thnx man i found your code god bless you always...im newbie

    • @robojax
      @robojax  3 ปีที่แล้ว

      Glad I could help. Please watch this 30 minuet Arduino course and you will learn very important things about Arduino th-cam.com/video/Mbb2xa1WcRM/w-d-xo.html

  • @mrbigbluff21
    @mrbigbluff21 11 หลายเดือนก่อน

    Assuming you can also turn on/off the light bulb through code in Arduino, right? If so will this sync up and allow you to either manually turn on/off through the button OR turn on/off through code? I'm trying to figure out if I can use this example in a real life scenario where I can control manually and remotely and have everything play nice together. Thanks!

  • @rajitheentechnology9058
    @rajitheentechnology9058 3 ปีที่แล้ว

    Thank you sir.
    I expect to your more videos

    • @robojax
      @robojax  3 ปีที่แล้ว +1

      So nice of you

  • @neofytos_theodoridis
    @neofytos_theodoridis 4 ปีที่แล้ว

    .....from Thessaloniki, thank you very much for your help

    • @robojax
      @robojax  4 ปีที่แล้ว

      You are welcome. Ahmad from Canada

  • @mattzelonka1189
    @mattzelonka1189 5 ปีที่แล้ว

    Seriously you saved me from going nuts..

    • @robojax
      @robojax  5 ปีที่แล้ว

      I am pleased hearing that.

  • @_ranger_hridoy_6213
    @_ranger_hridoy_6213 2 ปีที่แล้ว +1

    Thank you boss

  • @MrAlinkarl
    @MrAlinkarl 4 ปีที่แล้ว

    nice video....keep up the good work.....

    • @robojax
      @robojax  4 ปีที่แล้ว

      Thanks.

  • @ovindusadeepa3594
    @ovindusadeepa3594 2 หลายเดือนก่อน +1

    Thank you Good video

    • @robojax
      @robojax  2 หลายเดือนก่อน

      Glad you enjoyed it

  • @johnmarovich2637
    @johnmarovich2637 4 ปีที่แล้ว

    Thank you for this great video! I'm attempting to use this principle with an LED, but I'm having trouble adding a fade time. I would like to push the button, then the LED fades up in 4 seconds. Then push the button again and the LED fades off in 4 seconds. I've adjusted your code to work with a MOSFET, I just need help adding the dimmer fade. Any ideas?

    • @robojax
      @robojax  4 ปีที่แล้ว

      You are welcome. Your project is different. The output on this project is working like switch either ON or OFF. For fading we need PWM. Here I have written this code which I have not tested but it shoudl work. www.codepile.net/pile/4XyqJNXd please let me know

    • @DIYUSTHAD
      @DIYUSTHAD 4 ปีที่แล้ว

      If you want to fade on/off a 3v or 5v LED then you don't need a MOSFET, the LED can be directly controlled from any PWM support pin of Arduino.

  • @depup2404
    @depup2404 2 ปีที่แล้ว

    Excellent video. What if i wanted to add two or more then two push buttons? Thankyou

    • @robojax
      @robojax  2 ปีที่แล้ว +1

      just define all pins and variables . I have explained it fully. so pay attention to the code, watch it 2, 3, , 4 or 10 times until you know how it works. I can assure you can you do it. Here is my ***** Free Arduino Course ****
      Arduino Step by Step Course (over 100 lectures) Starts here robojax.com/L/?id=338

  • @RS18DESIGNS
    @RS18DESIGNS 6 ปีที่แล้ว

    Great video. Very helpful thank you so much.
    Please upload tutorial for TFT touch display with arduino while also using other sensors like temperature and humidity sensor and show that data on tft display

    • @robojax
      @robojax  6 ปีที่แล้ว +1

      Thank you. Sure will do that. I have add it into my list.

    • @RS18DESIGNS
      @RS18DESIGNS 6 ปีที่แล้ว

      Robojax thank you a lot. I will be waiting.

  • @Kangmasanas
    @Kangmasanas 3 ปีที่แล้ว +1

    Thank you

  • @Tulfonatic-sarcasticsm
    @Tulfonatic-sarcasticsm 6 ปีที่แล้ว

    hellow robojax.. nice video..... i have a question how to make connection if u dont have a resistor.. only using pull up code?

    • @robojax
      @robojax  6 ปีที่แล้ว

      Yes you can I have used in many of my project.

  • @jayoli7073
    @jayoli7073 3 ปีที่แล้ว +1

    Hi
    This is a very cool idea. Do you still have the code for it? Can't seem to find it in the description.

    • @robojax
      @robojax  3 ปีที่แล้ว +1

      I have over 400 and all links are in the description. I just checked it and it is there.

  • @somasiriperumburiarachchig9628
    @somasiriperumburiarachchig9628 3 ปีที่แล้ว

    Thank you very much

    • @robojax
      @robojax  3 ปีที่แล้ว

      You are welcome

  • @mark62726
    @mark62726 5 ปีที่แล้ว

    Hi man, nice video.
    I have a question, when you turn on the arduino the load is on automaticly?
    I have a home project where i want to conect a water pump but in power fail i dont want to be on when power comes back, just remain off

    • @robojax
      @robojax  5 ปีที่แล้ว

      Thank you. I should have done that. I just updated the code you can get it. I added digitalWrite(relayPin, HIGH); inside the setup()

  • @qasershah2000
    @qasershah2000 3 ปีที่แล้ว

    I like your video and it helped me. One thing I am trying to do but it's not working with that. Let me know can I use wall switch button which is used for 220V appliances? If so then how can I use it, please help me about that. Thank you

    • @robojax
      @robojax  3 ปีที่แล้ว

      this is the video for you. I connected a bulb, you connect a fridge or heater or anything. as long as you pay attention to the current rating of the relay. Read your relay and make sure don't connect a load beyond the limit of the current handling of relay.

  • @Dasgath
    @Dasgath 4 ปีที่แล้ว +1

    I been looking for a neat solution for this (i was looking for a way to control my relay with webserver and also a button!) and seemed like I couldnt find one at all, here and in other videos the code seems convoluted.
    So i actually stopped for 5 minutes and came out with a more simpler solution! Just follow this logic:
    1- The normal button state is always HIGH until its pushed down (LOW)
    2- That means you can write a comand that recognizes when the button is LOW during the two possible scenarios; if relaypin is LOW or HIGH
    3- So logically, -if relaypin is HIGH and you press the button (buttonpin LOW again), te relaypin should change to LOW (in a "normally open" setting that means the lights would turn ON)
    -if relaypin is LOW and you presss the button (buttonpin LOW), the relaypin should change to HIGH (in a "normally open" setting that means the lights would turn OFF)
    So following that idea:
    int relaypin =7;
    int buttonpin = 8;
    void setup() {
    pinMode(buttonpin, INPUT);
    digitalWrite(relaypin, HIGH); //This is nesesary for your relay to start in HIGH at startup, so it wont switch on during the few microseconds it takes to switch states)
    pinMode(relaypin, OUTPUT);
    void loop() {
    if (digitalRead(buttonpin) == LOW && digitalRead(relaypin) == HIGH) {
    delay (400);
    digitalWrite(relaypin, LOW);
    }
    if (digitalRead(buttonpin) == LOW && digitalRead(relaypin) == LOW) {
    delay (400);
    digitalWrite(relaypin, HIGH);
    }
    You need that delay in the middle (maybe even make it longer) to prevent your relay from switching at the speed of light.
    Im sure even I can come up with a way to prevent it from keep switching if you keep it pressed long enough.
    This works well if you were planning to use it with other code, since it is almost isolated in terms of variables.

    • @robojax
      @robojax  4 ปีที่แล้ว +1

      Thank you for your comment and code. It seems to be working. Same task can be done in many ways.

  • @thehrithikful
    @thehrithikful 5 ปีที่แล้ว +1

    Thank you so much it was helpful
    but I'm facing a problem in coding of push button switch , I want the sensor value to be saved in a reference when push boutton is pressed
    CODE:
    int sensorPin = A0;
    int buttonPin =7 ;
    int LED = 8;
    void setup() {
    pinMode(buttonPin, INPUT_PULLUP);
    pinMode(LED, OUTPUT);
    pinMode(sensorPin, INPUT);
    Serial.begin(9600);
    }
    void loop(){
    int reff;
    int sensorValue = analogRead(sensorPin);
    int buttonValue = digitalRead(buttonPin);
    while(buttonValue == LOW)
    {
    reff = analogRead(sensorPin);
    Serial.println(sensorValue);
    }
    Serial.println(reff);
    delay(100);
    }
    PROBLEM:
    if i press the button then sensor value should be displayed and get saved to reff , but both are not happening and reff value is not changing it stays at 0
    button is working fine ,Every component is working fine i hope that you could help me out in this one
    Thanks in advance

  • @wan_gitaris0875
    @wan_gitaris0875 4 ปีที่แล้ว +1

    thank you for your video, i want to ask about led light, why the led turn on but the relay turn off. and the opposite, this is my condition, in yours led light on the relay turn on

    • @robojax
      @robojax  4 ปีที่แล้ว

      You are incorrect wiring on the relay NO, NC. Watch the video again.

    • @wan_gitaris0875
      @wan_gitaris0875 4 ปีที่แล้ว

      @@robojax thanks. i have solved the problem. but i dont know what project must i create with this arduino. so i leave arduino for now. and back to my daily work. thanks again.

  • @danielkieliszczyk3291
    @danielkieliszczyk3291 3 ปีที่แล้ว

    Great video. I have a question how to modify it to have 2 buttons that control one realy (bulb). Application in stairs.

    • @robojax
      @robojax  3 ปีที่แล้ว

      that needs separate project. can't be explained by few line.

    • @danielkieliszczyk3291
      @danielkieliszczyk3291 3 ปีที่แล้ว

      @@robojax Can you preapre video are rather you are not inreasted.

  • @jung3043
    @jung3043 6 ปีที่แล้ว

    hello mr robojax~
    its really nice tutorial~
    i am a newbie abour arduino and electronics.
    i want to ask question, int lighton, is it for what? int for bulb or something? i still dont understand about this code.

    • @robojax
      @robojax  6 ปีที่แล้ว

      int lightON = 0;//light status
      it remembers the status (oN or OFF) of the light. Check the word "status"

  • @nisri1567
    @nisri1567 3 ปีที่แล้ว

    awesome video! great.
    Would you mind telling me the meaning of ( pushed = 1 - pushed); why do not give previousState newState

    • @robojax
      @robojax  3 ปีที่แล้ว

      Hello, I had to watch multiple videos to find the answer for you. here at 9:09 of this video th-cam.com/video/3EZecphNdAI/w-d-xo.html I've explained it.

    • @nisri1567
      @nisri1567 3 ปีที่แล้ว +1

      @@robojax ok thank you.

  • @mahdiazani6893
    @mahdiazani6893 3 ปีที่แล้ว

    hi Mr ahmed goood work can we change the push button withe a sensor like a thermocouple withe same cod of the push button

    • @robojax
      @robojax  3 ปีที่แล้ว

      HI, here the the thermocouple video that you control a relay th-cam.com/video/dVh77wT-4Ao/w-d-xo.html always search my channel. I have over 440 videos (Nov 2020) and you will find useful tutorial th-cam.com/users/robojaxTVvideos

    • @robojax
      @robojax  3 ปีที่แล้ว

      -Ahmed- Ahmad

  • @padmavathibhbh308
    @padmavathibhbh308 5 ปีที่แล้ว

    Hello sir I have seen your video .It is good for one switch ! What about 5-10 switchs

    • @robojax
      @robojax  5 ปีที่แล้ว

      Hi,, you can use the code in this video to control as many bulbs you like: th-cam.com/video/Wbm3MCMgM_s/w-d-xo.html

  • @AMPACUSA
    @AMPACUSA 4 ปีที่แล้ว

    Can you have this push button to keep the light on for a preset time for example for 30 seconds and turn off by itself?

    • @robojax
      @robojax  4 ปีที่แล้ว

      Then you don't need this. You can use this video th-cam.com/video/6DGQhQgr7Ak/w-d-xo.html

  • @cyberstar251
    @cyberstar251 ปีที่แล้ว

    how to i alter the code to make it so the switch only turns the relay on wile the switch is pressed? im planning to use this with a relay shield for a robotic charging base that only turns on when the robot parks on it to avoid causing a short when the contacts touch.

    • @robojax
      @robojax  ปีที่แล้ว

      learn about push button in this video th-cam.com/video/yyJrqFKn-X4/w-d-xo.html

  • @bayuanantasurya
    @bayuanantasurya 3 ปีที่แล้ว

    Thank, Great video.
    I have a question, in the end of the video, resistor leg is in the positive? But in the beginning, resistor leg is in the negative. Hmm,

    • @robojax
      @robojax  3 ปีที่แล้ว

      Learn here why we need resistor or not with push button th-cam.com/video/TTqoKcpIWkQ/w-d-xo.html

    • @bayuanantasurya
      @bayuanantasurya 3 ปีที่แล้ว

      @@robojax thank you very much

  • @norviniinasol7993
    @norviniinasol7993 5 ปีที่แล้ว

    Thank you sir.

    • @robojax
      @robojax  5 ปีที่แล้ว

      you are welcome.

  • @krypteiawxb
    @krypteiawxb 3 ปีที่แล้ว

    Hi. Thanks for the infomative video. I've connected the output of the relay (coms & NO) with 2 jumper wires connected to each other, then to an LED bulb in a breadboard. But it doesn't seemed to light up the LED. why is it so?? and also the wire connecting the output of relay is of the same terminal right (same Single wire)??

    • @robojax
      @robojax  3 ปีที่แล้ว

      Hi, does the relay clicks? Do you hear that sound of it? If not then either you changed the code or wiring has issue. Check it.

    • @krypteiawxb
      @krypteiawxb 3 ปีที่แล้ว

      @@robojax hi yes the relay is clicking with LED blinking when linked with arduino code. But serve no output signal.

    • @robojax
      @robojax  3 ปีที่แล้ว

      If relay works then you fix the wiring from relay to your load

    • @krypteiawxb
      @krypteiawxb 3 ปีที่แล้ว

      @@robojax yes it is working now. thank you!

  • @Prolinepumps
    @Prolinepumps 2 ปีที่แล้ว

    HO would you change the code to have "3 presses of the button - ON, 3 more presses of button - OFF" ... then start over?

    • @robojax
      @robojax  2 ปีที่แล้ว

      Hello, you can learn it from this video th-cam.com/video/OSwleCBlkuI/w-d-xo.html

  • @PetPeePee
    @PetPeePee 6 ปีที่แล้ว +2

    Thank You 10+

    • @robojax
      @robojax  6 ปีที่แล้ว

      You are welcome.

    • @PetPeePee
      @PetPeePee 6 ปีที่แล้ว

      I DID IT Thank YOU I Realy need it THANK YOU

  • @TopEndTutorial
    @TopEndTutorial 5 ปีที่แล้ว +3

    Will the push button remain the same state after reset

    • @robojax
      @robojax  5 ปีที่แล้ว +2

      Watch the video.

  • @vtigertest7473
    @vtigertest7473 3 ปีที่แล้ว

    Hi SIr,
    May i know which switch you are using i need same kind of switches to use in our project.
    Is this push once power on push again to power off switch?
    please let me know the part number.

    • @robojax
      @robojax  3 ปีที่แล้ว

      Hello, you can get Push buttons from Amazon: amzn.to/3eFlwWN

  • @ahmadalbabchannel4412
    @ahmadalbabchannel4412 3 ปีที่แล้ว

    How to control forward and revese motor using switch and the programing ?

    • @robojax
      @robojax  3 ปีที่แล้ว

      see my comment reply to your other comment. I can see both or all comments on the same page.

  • @negan6437
    @negan6437 5 ปีที่แล้ว

    What version of fritzing is used? Thanks for who can answer :)

    • @robojax
      @robojax  5 ปีที่แล้ว

      I have not looked at version. Every I believe for this purpose, any version will work. I have also edited the image in photoshop.

  • @ser7ser7i
    @ser7ser7i 5 ปีที่แล้ว

    Thank you.

    • @robojax
      @robojax  5 ปีที่แล้ว

      you are welcome.

  • @lexasolopow
    @lexasolopow 2 ปีที่แล้ว

    //Thank so much,
    I// believe this more self-explanatory
    int val = LOW; // push value from pin 2
    int lightON = LOW;//light status
    int pushed = LOW;//push status

  • @cattleranch2462
    @cattleranch2462 5 ปีที่แล้ว

    Robo, would you be willing to build a script to control a few linear actuator using and ardunio? Please let me know

    • @robojax
      @robojax  5 ปีที่แล้ว

      Hi, I am sorry I am very busy with full time job, research work and TH-cam. I might make a video in the future.

  • @madhukeshnp
    @madhukeshnp 6 ปีที่แล้ว

    hello !
    Robojax !! Nice tutorial. I tried the single channel relay code and it just worked fine on my nodemcu. so i thought of making it 4 channel and created my own code referring to single channel code of yours.. But the relay randomly turns on and off. dont know where hv gone wrong. can you please help me out? Thanks in advance...

    • @robojax
      @robojax  6 ปีที่แล้ว

      Hi, Thank you for the complement. Have you looked at the second code at the bottom of the page which shows how to control 2 relay and 2 buttons :robojax.com/learn/arduino/?vid=robojax-pushButton-on-off
      I am sure once you look at it, it would be clear. Let me know if further help is needed.

    • @madhukeshnp
      @madhukeshnp 6 ปีที่แล้ว

      Thank you so much for the quick response. Yes after having a look at the 2 channel relay control , then i created the 4 channel code. But its not working as expected. Can you please provide me your email address so that i can mail you the code. Or please ping me on my mail madhukeshnp@gmail.com .

  • @mizumiya_akio
    @mizumiya_akio 4 ปีที่แล้ว

    can you show how to create automatic light on/off with timer use relay on arduino with up and down push button for chose timer.

    • @robojax
      @robojax  4 ปีที่แล้ว

      I have two video one without LCD and another with LCD, Robojax Relay Timer. th-cam.com/video/6DGQhQgr7Ak/w-d-xo.html and th-cam.com/video/BhEIFzFSMuE/w-d-xo.html using push button will not make sense. How do you know what is the set time? You will need to have display to tell you the time.

  • @Cowboy-yv9xl
    @Cowboy-yv9xl 3 ปีที่แล้ว

    Thank you bro
    I have a question 🤔
    When I press the push button the relay turn off and the led turn on
    How can I turn them on together?

    • @robojax
      @robojax  3 ปีที่แล้ว

      They should turn on together because they are after each other in the code , unless you changed it. Or change it to work together.

  • @franciscoratusznei8012
    @franciscoratusznei8012 4 ปีที่แล้ว

    use a resistor on the buttom pin (between pin 2 and ground in this case ) to avoid a wrong input value, my input was always high because of that

    • @robojax
      @robojax  4 ปีที่แล้ว +1

      You don't need resistor, i used "INPUT_PULLUP" to eliminate the usage of resistor. Watch my video on why use resistor th-cam.com/video/TTqoKcpIWkQ/w-d-xo.html

  • @RamZiTO-369
    @RamZiTO-369 5 ปีที่แล้ว

    how would i add a 3rd mode on 3rd click of button for blink???

    • @chbonnici
      @chbonnici 5 ปีที่แล้ว

      see video in U- tube "th-cam.com/video/ojflP6pvTMc/w-d-xo.html"

  • @nikosbillis
    @nikosbillis 6 ปีที่แล้ว +1

    How it could stay on for 10min and then turn off. Without the delay() fuction.
    Thanks

    • @robojax
      @robojax  6 ปีที่แล้ว

      yes after you turn the relay ON, set delay (10000); But this code is to keep the LIGHT on and wait for another push to go OFF.
      use this goo.gl/C7vJqx and connect relay to pin 10. After this line digitalWrite(10, HIGH); put this delay (10000);
      and it will keep the light ON for 10 min and then goes OFF.

    • @nikosbillis
      @nikosbillis 6 ปีที่แล้ว

      I' d like to do tha without the delay(10000). Because the delay holds all the loop. Is it posible to do that with millis()?

    • @robojax
      @robojax  6 ปีที่แล้ว

      if you don't like to use delay(), then using mills() you can do it. Please have a look at this example at the end of page www.lucadentella.it/en/2015/07/21/arduino-delay-vs-millis/

  • @IvanMusic7
    @IvanMusic7 3 ปีที่แล้ว

    Como puedo hacerlo con Nodemcu para encender y apagar con el botón y también por wifi ?

    • @robojax
      @robojax  3 ปีที่แล้ว

      th-cam.com/video/wdgWdxV60dg/w-d-xo.html

  • @kanidu3522
    @kanidu3522 2 ปีที่แล้ว

    Hi , when the pushbutton is being pressed , current from the 5v pin of the Arduino will travel to gnd through the push button , wouldn't this short circuit the Arduino ?

    • @robojax
      @robojax  2 ปีที่แล้ว

      It seems you have not watch the video or have skipped. We never connect a switch one side to 5v and the other side to ground. Of course it will short circuit it. Watch the video again without skipping

    • @kanidu3522
      @kanidu3522 2 ปีที่แล้ว

      @@robojax I am sorry , I meant the I/O pin (pin2 ) , that pin is directly connected via the button to the ground

    • @robojax
      @robojax  2 ปีที่แล้ว

      please watch the other video which is only about push button switch. I have replied.

  • @richthomason4306
    @richthomason4306 4 ปีที่แล้ว

    I'd like to use code for trains set keto turnouts. It's simple and I understand it. I have played around with the code. I like to have one button to turn on and then off 1 second later.(auto turn off the relay). I have played around will millsec(), Delay () I just cannot get it right.

    • @robojax
      @robojax  4 ปีที่แล้ว

      I will reply to all Subscriber's 🔔 questions. So make sure to Subscribe.😊
      Please like 👍 the video and type simple word in the comment. It helps me a lot.
      Here are my videos on millis th-cam.com/users/robojaxTVsearch?query=millis

  • @Quantum_innovations
    @Quantum_innovations 6 ปีที่แล้ว

    HI, thanks for this nice video.
    I need a little help to add delay of 2 seconds before turning on the relay and when button pressed will off the relay. the precess should be repeated llike -
    1. pushed button - delay of 2 secs then relay on.
    2. again pushed button - relay off.
    3. pushed button - delay of 2 secs then relay on.
    4. again pushed button - relay off..............etc
    the process repeats with button press.....

    • @Quantum_innovations
      @Quantum_innovations 6 ปีที่แล้ว

      can the same be added in your above relay code

    • @robojax
      @robojax  6 ปีที่แล้ว +1

      You are welcome. Yes it is easily doable. Just add delay(2000); after the Serial.println("Light ON");
      like this
      Serial.println("Light ON");
      delay(2000);
      See the full code I have customized for you: codeshare.io/a3ZQjg
      test it and let me know.

    • @Quantum_innovations
      @Quantum_innovations 6 ปีที่แล้ว

      Dear robojax,
      extreme thanks for your kind reply. the code works. but the real problem i am facing is to add a delay of 2 seconds in the switch case-2 of below code.
      I need a delay of 2 secs only in case-2 and all other case should work without delay. i tried to add delay command but it pauses all next process. plz help if possible here..... the delay location i have mentioned in below code-----....
      int input = 2;
      int output1 = 3;
      int output2 = 4;
      int output3 = 8;
      int output4 = 9;
      int output5 = 10;
      int output6 = 11;
      int state = 0;
      int old =0;
      int buttonpoll=0;
      void setup() {
      pinMode(input, INPUT_PULLUP);
      pinMode(output1, OUTPUT);
      pinMode(output2, OUTPUT);
      pinMode(output3, OUTPUT);
      pinMode(output4, OUTPUT);
      pinMode(output5, OUTPUT);
      pinMode(output6, OUTPUT);
      digitalWrite(output1, LOW);
      digitalWrite(output2, LOW);
      digitalWrite(output3, LOW);
      digitalWrite(output4, LOW);
      digitalWrite(output5, LOW);
      digitalWrite(output6, LOW);
      }
      void loop() {
      buttonpoll = digitalRead (input);
      if (buttonpoll ==1){
      delay (80);
      buttonpoll = digitalRead (input);
      if (buttonpoll==0){
      state = old + 1;
      }}
      else
      {
      delay(100);}
      switch(state){
      case 1:
      digitalWrite(output3, LOW);
      digitalWrite(output4, HIGH);
      digitalWrite(output5, LOW);
      digitalWrite(output6, HIGH);
      digitalWrite(output1, HIGH);
      digitalWrite(output2, HIGH);
      old = state;
      break;
      case 2:
      digitalWrite(output3, HIGH);
      digitalWrite(output4, LOW);
      digitalWrite(output5, HIGH);
      digitalWrite(output6, LOW);
      digitalWrite(output1, LOW);
      digitalWrite(output2, LOW);
      //i need here a break of 2 seconds and continue the output1 and 2 High, also continue to next switch case.
      digitalWrite(output1, HIGH);
      digitalWrite(output2, HIGH);
      old = state;
      break;
      default:
      digitalWrite(output1,LOW);
      digitalWrite(output2, LOW);
      digitalWrite(output3, LOW);
      digitalWrite(output4, LOW);
      digitalWrite(output5, LOW);
      digitalWrite(output6, LOW);
      old = 0;
      break;

      }
      }

    • @robojax
      @robojax  6 ปีที่แล้ว

      delay() will halt all process. This is that it does. You can't continue to the rest of the code before the delay time has not reached to the end.
      Please use the chareCode.io. you could directly edit the code or create new code see this snag.gy/5jXKr9.jpg
      After you made change or you created code, just share address.

  • @brendonwilliams6464
    @brendonwilliams6464 5 ปีที่แล้ว

    I can't find any videos detailing how to wire this up without using a relay, all I want to do is turn the LED on with a press of the button, and have it stay on until the next press

    • @robojax
      @robojax  5 ปีที่แล้ว

      If you know how to connect LED, then in this code connect your LED to pin 10. Or watch this video th-cam.com/video/2WwedCRwmgA/w-d-xo.html and then come back to this video.

  • @IncredibleMachines
    @IncredibleMachines 5 ปีที่แล้ว

    thx

    • @robojax
      @robojax  5 ปีที่แล้ว

      You are welcome.

  • @rafaelsolis8599
    @rafaelsolis8599 5 ปีที่แล้ว

    Will it be the same diagram if i use DC motor ?

    • @robojax
      @robojax  5 ปีที่แล้ว

      Load is load. Doesn't matter if AC bulb or DC motor. As long as the amount of current the motor needs doesn't exceed the rating of relay, it will work.

  • @Mahmudulhasan-or5zu
    @Mahmudulhasan-or5zu 3 ปีที่แล้ว

    Nice bro

    • @robojax
      @robojax  3 ปีที่แล้ว

      Thanks

  • @MrAlinkarl
    @MrAlinkarl 4 ปีที่แล้ว

    i test the code, after uploading the code it will on and off the relay. after 3 sec the relay will on again, but i did not press the button. can you help or check again the code . thank you...

    • @robojax
      @robojax  4 ปีที่แล้ว

      you must have changed the code. it should work.

  • @azwarfareedhasni3413
    @azwarfareedhasni3413 5 ปีที่แล้ว +1

    Sir. How can we do it wirelessly?

    • @robojax
      @robojax  5 ปีที่แล้ว +1

      Watch this video. You need Bluetooth module th-cam.com/video/-E9J9ExdZ20/w-d-xo.html

  • @Jus10aaron
    @Jus10aaron 5 ปีที่แล้ว

    Is it possible to add bluetooth and android app with Push button

    • @robojax
      @robojax  5 ปีที่แล้ว

      here check it out th-cam.com/video/-E9J9ExdZ20/w-d-xo.html

  • @boorkop10
    @boorkop10 5 ปีที่แล้ว

    Hello, top video!
    But I have a problem: everthing is as You have and I download the code but the led is ON and the relay is OF. When I push the bottem relay is ON but the led is OF. It is not on the same time. Have You any idea wath the problem is?

    • @robojax
      @robojax  5 ปีที่แล้ว

      You have connected your relay wires incorrectly. Watch the video again where I explained the relay wiring.

    • @boorkop10
      @boorkop10 5 ปีที่แล้ว

      @@robojax HI, it is not the ac lamp what is the problem; led on breadboard is ON, green led of the relay is OFF. Push the bottem;; green led on relay is ON, led on the bb is OFF

    • @robojax
      @robojax  5 ปีที่แล้ว

      I am sorry which LED? the LED on relay ? There is 2 LED on the relay. One is always ON. that is power. the 2nd turn ON when relay goes ON.

    • @boorkop10
      @boorkop10 5 ปีที่แล้ว

      @@robojax ok, You have a green led on the bb burning. Only the red led on the relay is burning I push the bottem, led on the bb is going out and the green led is going on.The green led on bb and the green led on the relay are not going buring at the same time that is de problem.

    • @robojax
      @robojax  5 ปีที่แล้ว

      Red is power showing there is power. Green is the actual ON and OFF. Do you hear click? you should hear click when green LED turns ON. If there is click all OK. it should work.

  • @sangarmutusamy9801
    @sangarmutusamy9801 6 ปีที่แล้ว

    Hi Mr. Robojak, i try to use the 2 button and relay code and it didn't work properly, only relay 2 can turn ON , relay 1 cannot ON. Can you pls help? But i also try the 1 relay code and it's work.

    • @robojax
      @robojax  6 ปีที่แล้ว

      HI Sangar, you are right. There were problem with the code and I fixed it. I have not tested it but it should work. Let me know if there is a problem.

    • @sangarmutusamy9801
      @sangarmutusamy9801 6 ปีที่แล้ว

      Hi Mr . Robojak, thank you very much for your quick reply, btw can you pls send me the correct code that you have fixed it pls, or can i know where can i get it? Thanks again sir.

    • @sangarmutusamy9801
      @sangarmutusamy9801 6 ปีที่แล้ว

      Great, i got it, thank you sir really appreaciate your quick response. Thank you again.

    • @adriandilena
      @adriandilena 6 ปีที่แล้ว

      Hello, I am having the same problem. Is there an updated code?

  • @gotta91
    @gotta91 4 ปีที่แล้ว

    is possible connect 3VDC in output?

    • @robojax
      @robojax  4 ปีที่แล้ว

      Arduino has 3.3V and 5V but not 3V. if you get 3.3V relay, and Arduino non with 3.3V, yes can.

    • @gotta91
      @gotta91 4 ปีที่แล้ว

      @@robojax without arduino, i want use a 2032 3v battery

  • @bgable7707
    @bgable7707 3 ปีที่แล้ว

    I can't find the wiring schematic! Ideally the link to the code and wiring diagrams should be easy to find, ie, at the beginning of the "See More" link. Yes, the code link points to another link which links to a udemy page to get the schematic, really?

    • @robojax
      @robojax  3 ปีที่แล้ว

      code is there but no schematic. you don't need it. I have explained it fully. you can draw it if you need it for school or project using this free software fritzing.org/ the link to the code is for sure there.

  • @harshinielectricals
    @harshinielectricals 4 ปีที่แล้ว

    Can u give me the program of 5 push buttons and one led to ON, 5 indicators for 5 push buttons , one reset button to OFF for all led

    • @robojax
      @robojax  4 ปีที่แล้ว

      I am sorry, I am very busy. What is application for this? if a lot of people need it, I will consider working on it.

    • @harshinielectricals
      @harshinielectricals 4 ปีที่แล้ว

      @@robojax it's for my home emergency switch, security gaurd will reset the button to turn off the syren

  • @yasirballo788
    @yasirballo788 4 ปีที่แล้ว

    Can i make it in relay off state at first

    • @robojax
      @robojax  4 ปีที่แล้ว +1

      do you want to the relay to be OFF when you turn ON Arduino? as later we don't have first or second. it depends how you see it. Once you press it few times you will forget what is what.

  • @Dralientv
    @Dralientv 6 ปีที่แล้ว

    my adruino sey : pbuttonPin was not declaret in thids scope

    • @robojax
      @robojax  6 ปีที่แล้ว +2

      You must be doing something wrong. Please post your code in this page codeshare.io/ and it will create a URL (addres) for your code, then copy and paste the code by replying to this message.

  • @shell6263
    @shell6263 5 ปีที่แล้ว

    What if I create a toggle button in app inventor what will be the code of it in Arduino?

    • @robojax
      @robojax  5 ปีที่แล้ว +1

      Never heard of app inventor. But just checked it. it is totally different. you can apply the concept but different method.

    • @shell6263
      @shell6263 5 ปีที่แล้ว

      Robojax Okay thank you so much

  • @cipitillo
    @cipitillo ปีที่แล้ว

    can I use this code with espnow

    • @robojax
      @robojax  ปีที่แล้ว +1

      Don’t know what is espnow

  • @ofybc5560
    @ofybc5560 2 ปีที่แล้ว

    how can we use multiple relays and buttons

    • @robojax
      @robojax  2 ปีที่แล้ว +1

      I believe we have such project. Here is how to find Specific TH-cam Video in a channel bit.ly/findTH-camVideo

    • @ofybc5560
      @ofybc5560 2 ปีที่แล้ว

      @@robojax video’s not available

  • @MrAlinkarl
    @MrAlinkarl 4 ปีที่แล้ว

    i test the code, after uploading the code it will on and off the relay. after 3 sec the relay will on again, but i did not press the button.

    • @robojax
      @robojax  4 ปีที่แล้ว

      I just checked the code. it should not do it. Without pushing the switch it should not toggle the bulb. Check the code or wiring. if you use INPUT_PULLUP which is in the code, it should not turn ON or oFF by itself.

  • @adilabusafa
    @adilabusafa 9 หลายเดือนก่อน +1

    أهلاً وسهلاً ومرحباً بك-يتعذر التعليق-لا أعلم .

  • @lovnishkataria426
    @lovnishkataria426 5 ปีที่แล้ว

    Sir i want the bulb to be switched on for 7 seconds and then automatically shut down and again turn on for 7 sec only if push switch is pressed else bulb remains off.
    Plz suggest me how to do
    It will solved by only change in programming of audrino??
    Plz reply 🙏

    • @robojax
      @robojax  5 ปีที่แล้ว +1

      Hi, Yes. it is very simple. See the code here th-cam.com/video/58XWVDnB7Ss/w-d-xo.html
      You have to watch the video to understand what I say.
      here is the code codeshare.io/5wEdZP

    • @lovnishkataria426
      @lovnishkataria426 5 ปีที่แล้ว

      @@robojax thankyou very much for your help🙏🙏🙏

    • @robojax
      @robojax  5 ปีที่แล้ว

      You are welcome.

  • @CuddleStories
    @CuddleStories 4 ปีที่แล้ว

    NC actually stands for normally closed. You said normally connected. Love your videos though.

    • @robojax
      @robojax  4 ปีที่แล้ว

      Thank you very much.

  • @TheRokkis
    @TheRokkis 4 ปีที่แล้ว

    Usually we use booalean for 1 and 0 states

    • @robojax
      @robojax  4 ปีที่แล้ว +1

      by definition Boolean has value of TRUE or FALSE but in Arduino IDE, if you use 1 and 0 it wont 'give you error and works.

  • @debrajbarman9769
    @debrajbarman9769 5 ปีที่แล้ว

    How to control relay with keypad ?

    • @robojax
      @robojax  5 ปีที่แล้ว

      Here are my videos on keypad th-cam.com/users/robojaxTVsearch?query=keypad
      just combined them.

  • @hillellazar9656
    @hillellazar9656 3 ปีที่แล้ว

    How big is the resistor?

    • @robojax
      @robojax  3 ปีที่แล้ว

      you made me watch the video as this video doesn't need LED. But it has and I mentioned that if you use a relay you don't need LED. but in case you did, the color of the resistor is BLUE, Grey, Brown which is 680Ω but you can use 300Ω to 1000Ω. you and do google/bing search for "resistor color code" you will get something like this www.allaboutcircuits.com/tools/resistor-color-code-calculator/ where you can select color and read the resitors value.

    • @hillellazar9656
      @hillellazar9656 3 ปีที่แล้ว

      Thank you!

    • @robojax
      @robojax  3 ปีที่แล้ว

      you are very welcome.

  • @tanzirahamad8169
    @tanzirahamad8169 5 ปีที่แล้ว

    what will happen, if you press the button for 3 minutes? please,

    • @robojax
      @robojax  5 ปีที่แล้ว

      as soon as you push, if the light is ON will turn OFF and stay OFF and if the light is OFF, as soon as you push the light will turn ON and will stay on until you release the button and push again. Doesn't matter if you keep if for 1 min or 1 hour. no affect.

    • @tanzirahamad8169
      @tanzirahamad8169 5 ปีที่แล้ว

      @@robojax thank you sir

  • @javeidelectronics6982
    @javeidelectronics6982 5 ปีที่แล้ว +1

    SIR plz help me

    • @robojax
      @robojax  5 ปีที่แล้ว +1

      you did not mention the problem. how can I help you?

  • @Inferlogist
    @Inferlogist 4 ปีที่แล้ว

    where is the sketch of this video ?

    • @robojax
      @robojax  4 ปีที่แล้ว

      I just watched the video making sure I have mentioned it and yes I have mentioned it that the code is under the video in the description or you can visit my website. here is how snipboard.io/EG4O2l.jpg

  • @Gunham20
    @Gunham20 3 ปีที่แล้ว

    NC is normally closed. Not normally connected

    • @robojax
      @robojax  3 ปีที่แล้ว

      You are right. But connected make more sense than closed. For some people closed means the path to current is closed. Which means not connected.

  • @3hdalkfiri320
    @3hdalkfiri320 4 ปีที่แล้ว

    Thanks but this little code for everything I did
    int relay1 =11;
    int but =9;
    int val ;
    void setup() {
    pinMode(but,INPUT_PULLUP);
    pinMode(relay1,OUTPUT);
    }
    void loop() {
    val=digitalRead(relay1);
    if (digitalRead(but)==LOW){
    digitalWrite(relay1,!val);
    delay(500);
    }
    }
    onnnlyyyy

    • @robojax
      @robojax  4 ปีที่แล้ว +1

      you are welcome. Yes. there are many ways to do it.

  • @nessrinekrouma5
    @nessrinekrouma5 3 ปีที่แล้ว

    thank you sir ,, but please code

    • @robojax
      @robojax  3 ปีที่แล้ว

      The link is in the description under tthe video.

    • @nessrinekrouma5
      @nessrinekrouma5 3 ปีที่แล้ว

      @@robojax thank you sir

    • @robojax
      @robojax  3 ปีที่แล้ว

      you are welcome.

    • @nessrinekrouma5
      @nessrinekrouma5 3 ปีที่แล้ว

      @@robojax hi sir, please ,,, i need your help very urgent
      how to ensure the wiring between an ACS712 5A sensor + 5v relay + Arduino + a Push button
      (I trained to carry out my end of study project. The objective of this project is therefore to find a solution to the problems of Smartphone charger accidents. home fires start,
      We have arrived at an intermediate investigation between the network and the charger. This media is automatically disconnected when the charger is empty or when the battery charge level reaches 100%.) (When you appear on the push button, the phone is charging and when the charger is
      empty or the battery is 100% reached, the relay disconnects.)

  • @nanaya1519
    @nanaya1519 4 ปีที่แล้ว

    Sir where's the code?

    • @robojax
      @robojax  4 ปีที่แล้ว

      under the video in the description of the video.

  • @matlesterdivinagracia6528
    @matlesterdivinagracia6528 3 ปีที่แล้ว

    if I used pushbutton same as DOL starter
    will it work or not?

    • @robojax
      @robojax  3 ปีที่แล้ว

      what is DOL?

    • @matlesterdivinagracia6528
      @matlesterdivinagracia6528 3 ปีที่แล้ว

      @@robojax Direct On Line

    • @robojax
      @robojax  3 ปีที่แล้ว

      Okay, still I did not understand what you wan to do.