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

  Рет қаралды 133,627

Robojax

Robojax

Күн бұрын

Пікірлер: 237
@silonian
@silonian Жыл бұрын
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 Жыл бұрын
Glad I could help!
@desertengineer-z5c
@desertengineer-z5c 3 ай бұрын
Thanks for explaining
@heaven4261
@heaven4261 6 жыл бұрын
It's so cool. It has been a great help
@robojax
@robojax 6 жыл бұрын
Good to hear that. Thanks
@sushildamle3449
@sushildamle3449 3 жыл бұрын
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?
@Dasgath
@Dasgath 5 жыл бұрын
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 5 жыл бұрын
Thank you for your comment and code. It seems to be working. Same task can be done in many ways.
@kenneth123skate321
@kenneth123skate321 3 жыл бұрын
thank, very useful for mee, thanks !!!
@robojax
@robojax 3 жыл бұрын
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
@ovindusadeepa3594
@ovindusadeepa3594 9 ай бұрын
Thank you Good video
@robojax
@robojax 9 ай бұрын
Glad you enjoyed it
@MrAlinkarl
@MrAlinkarl 4 жыл бұрын
nice video....keep up the good work.....
@robojax
@robojax 4 жыл бұрын
Thanks.
@Dubot-f1v
@Dubot-f1v Жыл бұрын
Another cool video 😁
@IncredibleMachines
@IncredibleMachines 6 жыл бұрын
thx
@robojax
@robojax 6 жыл бұрын
You are welcome.
@chameeraabhishek2969
@chameeraabhishek2969 2 жыл бұрын
Very useful ,thanks
@TopEndTutorial
@TopEndTutorial 6 жыл бұрын
Will the push button remain the same state after reset
@robojax
@robojax 6 жыл бұрын
Watch the video.
@nawinlifehacks9978
@nawinlifehacks9978 6 жыл бұрын
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 6 жыл бұрын
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.
@Kangmasanas
@Kangmasanas 3 жыл бұрын
Thank you
@ibing02
@ibing02 6 жыл бұрын
very helpful!!! thanks a lot!
@robojax
@robojax 6 жыл бұрын
You are welcome.
@wan_gitaris0875
@wan_gitaris0875 5 жыл бұрын
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 5 жыл бұрын
You are incorrect wiring on the relay NO, NC. Watch the video again.
@wan_gitaris0875
@wan_gitaris0875 5 жыл бұрын
@@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.
@mrbigbluff21
@mrbigbluff21 Жыл бұрын
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 4 жыл бұрын
Thank you sir. I expect to your more videos
@robojax
@robojax 4 жыл бұрын
So nice of you
@jayoli7073
@jayoli7073 4 жыл бұрын
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 4 жыл бұрын
I have over 400 and all links are in the description. I just checked it and it is there.
@bartbonnyns
@bartbonnyns 4 жыл бұрын
Hello Robojax, Thnx a lot for your great KZbin, 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 жыл бұрын
Hi, you are welcome. here is my video on relay kzbin.info/www/bejne/hF7Jd55rZqqVbtU
@bayuanantasurya
@bayuanantasurya 4 жыл бұрын
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 4 жыл бұрын
Learn here why we need resistor or not with push button kzbin.info/www/bejne/ioXUoH6Zpa6KobM
@bayuanantasurya
@bayuanantasurya 3 жыл бұрын
@@robojax thank you very much
@danielkieliszczyk3291
@danielkieliszczyk3291 4 жыл бұрын
Great video. I have a question how to modify it to have 2 buttons that control one realy (bulb). Application in stairs.
@robojax
@robojax 4 жыл бұрын
that needs separate project. can't be explained by few line.
@danielkieliszczyk3291
@danielkieliszczyk3291 4 жыл бұрын
@@robojax Can you preapre video are rather you are not inreasted.
@gottisttot9
@gottisttot9 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.
@gottisttot9
@gottisttot9 4 жыл бұрын
@@robojax without arduino, i want use a 2032 3v battery
@_ranger_hridoy_6213
@_ranger_hridoy_6213 3 жыл бұрын
Thank you boss
@TheWindtalker2011
@TheWindtalker2011 4 жыл бұрын
hi thnx man i found your code god bless you always...im newbie
@robojax
@robojax 4 жыл бұрын
Glad I could help. Please watch this 30 minuet Arduino course and you will learn very important things about Arduino kzbin.info/www/bejne/g5PFY6uXZryWiK8
@mattzelonka1189
@mattzelonka1189 6 жыл бұрын
Seriously you saved me from going nuts..
@robojax
@robojax 6 жыл бұрын
I am pleased hearing that.
5 жыл бұрын
nice tutorial,tnx
@robojax
@robojax 5 жыл бұрын
You are welcome.
@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 ..
@adilabusafa
@adilabusafa Жыл бұрын
أهلاً وسهلاً ومرحباً بك-يتعذر التعليق-لا أعلم .
@mahdiazani6893
@mahdiazani6893 4 жыл бұрын
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 4 жыл бұрын
HI, here the the thermocouple video that you control a relay kzbin.info/www/bejne/mofLaGqtiZJnd9E always search my channel. I have over 440 videos (Nov 2020) and you will find useful tutorial kzbin.infovideos
@robojax
@robojax 4 жыл бұрын
-Ahmed- Ahmad
@vtigertest7473
@vtigertest7473 4 жыл бұрын
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 4 жыл бұрын
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.
@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 kzbin.info/www/bejne/hYTanZh5d9Geq6s
@shinjitsumasayoshi9072
@shinjitsumasayoshi9072 5 ай бұрын
I need exactly the same set up including 16 on and off toggle switch with 16 relay.
@robojax
@robojax 5 ай бұрын
Search my channel for 16 channel
@JasonDeLorenzo
@JasonDeLorenzo 5 жыл бұрын
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 5 жыл бұрын
You are welcome. Here is the simple form. You can use Relay instead of LED in this video kzbin.info/www/bejne/aIjalpd5h9ygnaM
@abrouguihelmi4789
@abrouguihelmi4789 5 жыл бұрын
Robojax q
@depup2404
@depup2404 3 жыл бұрын
Excellent video. What if i wanted to add two or more then two push buttons? Thankyou
@robojax
@robojax 3 жыл бұрын
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
@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 kzbin.info/www/bejne/r6qto6R8gNNgjpY
@AMPACUSA
@AMPACUSA 5 жыл бұрын
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 5 жыл бұрын
Then you don't need this. You can use this video kzbin.info/www/bejne/bHWqgpuHnNdqd80
@neofytos_theodoridis
@neofytos_theodoridis 5 жыл бұрын
.....from Thessaloniki, thank you very much for your help
@robojax
@robojax 5 жыл бұрын
You are welcome. Ahmad from Canada
@cipitillo
@cipitillo Жыл бұрын
can I use this code with espnow
@robojax
@robojax Жыл бұрын
Don’t know what is espnow
@norviniinasol7993
@norviniinasol7993 6 жыл бұрын
Thank you sir.
@robojax
@robojax 6 жыл бұрын
you are welcome.
@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.
@ofybc5560
@ofybc5560 3 жыл бұрын
how can we use multiple relays and buttons
@robojax
@robojax 3 жыл бұрын
I believe we have such project. Here is how to find Specific KZbin Video in a channel bit.ly/findKZbinVideo
@ofybc5560
@ofybc5560 3 жыл бұрын
@@robojax video’s not available
@azwarfareedhasni3413
@azwarfareedhasni3413 6 жыл бұрын
Sir. How can we do it wirelessly?
@robojax
@robojax 6 жыл бұрын
Watch this video. You need Bluetooth module kzbin.info/www/bejne/Y3ace2x7rcmNaJI
@mark62726
@mark62726 6 жыл бұрын
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 6 жыл бұрын
Thank you. I should have done that. I just updated the code you can get it. I added digitalWrite(relayPin, HIGH); inside the setup()
@nikosbillis
@nikosbillis 7 жыл бұрын
How it could stay on for 10min and then turn off. Without the delay() fuction. Thanks
@robojax
@robojax 7 жыл бұрын
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 7 жыл бұрын
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 7 жыл бұрын
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/
@nisri1567
@nisri1567 4 жыл бұрын
awesome video! great. Would you mind telling me the meaning of ( pushed = 1 - pushed); why do not give previousState newState
@robojax
@robojax 4 жыл бұрын
Hello, I had to watch multiple videos to find the answer for you. here at 9:09 of this video kzbin.info/www/bejne/aXa9lpamnbOXd6s I've explained it.
@nisri1567
@nisri1567 4 жыл бұрын
@@robojax ok thank you.
@kanidu3522
@kanidu3522 3 жыл бұрын
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 3 жыл бұрын
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 3 жыл бұрын
@@robojax I am sorry , I meant the I/O pin (pin2 ) , that pin is directly connected via the button to the ground
@robojax
@robojax 3 жыл бұрын
please watch the other video which is only about push button switch. I have replied.
@yasirballo788
@yasirballo788 5 жыл бұрын
Can i make it in relay off state at first
@robojax
@robojax 5 жыл бұрын
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.
@hillellazar9656
@hillellazar9656 4 жыл бұрын
How big is the resistor?
@robojax
@robojax 4 жыл бұрын
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 4 жыл бұрын
Thank you!
@robojax
@robojax 4 жыл бұрын
you are very 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!
@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 KZbin. I might make a video in the future.
@ser7ser7i
@ser7ser7i 5 жыл бұрын
Thank you.
@robojax
@robojax 5 жыл бұрын
you are welcome.
@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.
@rafaelsolis8599
@rafaelsolis8599 6 жыл бұрын
Will it be the same diagram if i use DC motor ?
@robojax
@robojax 6 жыл бұрын
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.
@Jus10aaron
@Jus10aaron 6 жыл бұрын
Is it possible to add bluetooth and android app with Push button
@robojax
@robojax 6 жыл бұрын
here check it out kzbin.info/www/bejne/Y3ace2x7rcmNaJI
@johnmarovich2637
@johnmarovich2637 5 жыл бұрын
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 5 жыл бұрын
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 5 жыл бұрын
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.
@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.
@qasershah2000
@qasershah2000 4 жыл бұрын
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 4 жыл бұрын
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.
@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"
@IvanMusic7
@IvanMusic7 4 жыл бұрын
Como puedo hacerlo con Nodemcu para encender y apagar con el botón y también por wifi ?
@robojax
@robojax 4 жыл бұрын
kzbin.info/www/bejne/rZXKiJeui5tjmsk
@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.
@negan6437
@negan6437 6 жыл бұрын
What version of fritzing is used? Thanks for who can answer :)
@robojax
@robojax 6 жыл бұрын
I have not looked at version. Every I believe for this purpose, any version will work. I have also edited the image in photoshop.
@boorkop10
@boorkop10 6 жыл бұрын
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 6 жыл бұрын
You have connected your relay wires incorrectly. Watch the video again where I explained the relay wiring.
@boorkop10
@boorkop10 6 жыл бұрын
@@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 6 жыл бұрын
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 6 жыл бұрын
@@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 6 жыл бұрын
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.
@brendonwilliams6464
@brendonwilliams6464 6 жыл бұрын
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 6 жыл бұрын
If you know how to connect LED, then in this code connect your LED to pin 10. Or watch this video kzbin.info/www/bejne/aIjalpd5h9ygnaM and then come back to this video.
@harshinielectricals
@harshinielectricals 5 жыл бұрын
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 5 жыл бұрын
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 5 жыл бұрын
@@robojax it's for my home emergency switch, security gaurd will reset the button to turn off the syren
@RamZiTO-369
@RamZiTO-369 6 жыл бұрын
how would i add a 3rd mode on 3rd click of button for blink???
@chbonnici
@chbonnici 6 жыл бұрын
see video in U- tube "kzbin.info/www/bejne/pZvJnYNspduHg8U"
@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.
@thehrithikful
@thehrithikful 6 жыл бұрын
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
@franciscoratusznei8012
@franciscoratusznei8012 5 жыл бұрын
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 5 жыл бұрын
You don't need resistor, i used "INPUT_PULLUP" to eliminate the usage of resistor. Watch my video on why use resistor kzbin.info/www/bejne/ioXUoH6Zpa6KobM
@shell6263
@shell6263 6 жыл бұрын
What if I create a toggle button in app inventor what will be the code of it in Arduino?
@robojax
@robojax 6 жыл бұрын
Never heard of app inventor. But just checked it. it is totally different. you can apply the concept but different method.
@shell6263
@shell6263 6 жыл бұрын
Robojax Okay thank you so much
@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: kzbin.info/www/bejne/jZPQZIB5gsyAldU
@Mahmudulhasan-or5zu
@Mahmudulhasan-or5zu 4 жыл бұрын
Nice bro
@robojax
@robojax 4 жыл бұрын
Thanks
@sangarmutusamy9801
@sangarmutusamy9801 7 жыл бұрын
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 7 жыл бұрын
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 7 жыл бұрын
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 7 жыл бұрын
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?
@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 жыл бұрын
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.
@richthomason4306
@richthomason4306 5 жыл бұрын
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 5 жыл бұрын
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 kzbin.infosearch?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 жыл бұрын
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.
@mizumiya_akio
@mizumiya_akio 5 жыл бұрын
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 5 жыл бұрын
I have two video one without LCD and another with LCD, Robojax Relay Timer. kzbin.info/www/bejne/bHWqgpuHnNdqd80 and kzbin.info/www/bejne/eJmoenmwe7iAq6c 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.
@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 .
@LemonTreeNOTfree
@LemonTreeNOTfree 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
@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.
@Inferlogist
@Inferlogist 5 жыл бұрын
where is the sketch of this video ?
@robojax
@robojax 5 жыл бұрын
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
@Dralientv
@Dralientv 6 жыл бұрын
my adruino sey : pbuttonPin was not declaret in thids scope
@robojax
@robojax 6 жыл бұрын
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.
@TheRokkis
@TheRokkis 5 жыл бұрын
Usually we use booalean for 1 and 0 states
@robojax
@robojax 5 жыл бұрын
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.
@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.
@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 жыл бұрын
Hi, Yes. it is very simple. See the code here kzbin.info/www/bejne/a2m7iIl6o6dqidU 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.
@tanzirahamad8169
@tanzirahamad8169 6 жыл бұрын
what will happen, if you press the button for 3 minutes? please,
@robojax
@robojax 6 жыл бұрын
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 6 жыл бұрын
@@robojax thank you sir
@CuddleStories
@CuddleStories 4 жыл бұрын
NC actually stands for normally closed. You said normally connected. Love your videos though.
@robojax
@robojax 4 жыл бұрын
Thank you very much.
@debrajbarman9769
@debrajbarman9769 6 жыл бұрын
How to control relay with keypad ?
@robojax
@robojax 6 жыл бұрын
Here are my videos on keypad kzbin.infosearch?query=keypad just combined them.
@nanaya1519
@nanaya1519 4 жыл бұрын
Sir where's the code?
@robojax
@robojax 4 жыл бұрын
under the video in the description of the video.
@nessrinekrouma5
@nessrinekrouma5 4 жыл бұрын
thank you sir ,, but please code
@robojax
@robojax 4 жыл бұрын
The link is in the description under tthe video.
@nessrinekrouma5
@nessrinekrouma5 4 жыл бұрын
@@robojax thank you sir
@robojax
@robojax 4 жыл бұрын
you are welcome.
@nessrinekrouma5
@nessrinekrouma5 4 жыл бұрын
@@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.)
@javeidelectronics6982
@javeidelectronics6982 6 жыл бұрын
SIR plz help me
@robojax
@robojax 6 жыл бұрын
you did not mention the problem. how can I help you?
@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 жыл бұрын
you are welcome. Yes. there are many ways to do it.
@DTurvold
@DTurvold 3 жыл бұрын
Thank you! Very nice video.
@somasiriperumburiarachchig9628
@somasiriperumburiarachchig9628 4 жыл бұрын
Thank you very much
@robojax
@robojax 4 жыл бұрын
You are welcome
Arduino Tutorial 28: Using a Pushbutton as a Toggle Switch
21:58
Paul McWhorter
Рет қаралды 301 М.
IL'HAN - Qalqam | Official Music Video
03:17
Ilhan Ihsanov
Рет қаралды 700 М.
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Arduino Push Button Relay Control
3:52
Viral Science - The home of Creativity
Рет қаралды 31 М.
Forklift Cylinder Repair The REBUILD Comes to Life! 🔧 | Part 2
1:03:06
Cutting Edge Engineering Australia
Рет қаралды 268 М.
15 Genius Home Hacks That Will Instantly Change Your Life
25:07
Arduino Basics 102: Control Structures, Variables, Interrupts
7:38
Push Button and LED control with the Arduino
4:38
Maker 101
Рет қаралды 334 М.
This Speed Test Will Change How You Buy Ethernet Cables!
8:00
IL'HAN - Qalqam | Official Music Video
03:17
Ilhan Ihsanov
Рет қаралды 700 М.