So in this video i am going to discuss that how we can connect our arduino with the push button, so i want to show you the circuit diagram, so this is the circuit diagram im going to use um. This is the push button, and here is the pull up resistor, which is connected with 5 volt power supply. Here i have the three rgb leds and those leds are connected with pin number 9 10 11. The program works like if i push this button, this input will go low and if i dont push this button, then our input will be connected with the 5 volt supply. So if i start the simulation see now the simulation is running. So initially you can see that all the leds are on and my input is actually high. You can see this red so on the high input. All of your leds are on okay, rgb leds, and when i push this button this one, then the led will start flashing so lets try to push this yeah. So when i push this button now there is a flashing and this is happening quite quickly, but you cant see it here very clearly when i will show you the actual demonstration, it will be clear, but there are a few things that i want to discuss you, Which actually took some time for me to sort out is that first of all, these leds are connected in common uh common anode mode, as you can see.

So all of these leds here are in common anode mode. It actually means that the positive side of these leds – or this is the positive side it is connected with the five volt supply and the negative side is connected with the output from the arduino its taking. So all the positives connected with the positive and negative side is uh connected here on the arduino, so this is common, so thats, why we call it common anode analogy. Also, there is a common cathode analogy where we connect all these grounds together this one this one and this ground together, and then we put put this with the common ground in this this case it will be common, cathode analogy right here. Also, i want to discuss this thing, which is a resistor which now i will call it a pull up configuration okay. So this is the pull up configuration of the resistor. So let me explain this thing. It is like, if you have this arduino board. This is the arduino board, and here you want to give the input supplier, so there are two methods you can connect the push button with this one is you connect the pull up, resistor as what i did and the other one is connecting a pull down resist If i want to connect it, the circuit will be like this, so this is my resistor. Okay, sorry for my drawing. So this is the resistor, and i put it this one to ground and here will be a push button.

This is the push button and this one is connected with the plus 5 volt okay. So this is the pull down configuration why its pulled down, because all the time, this side will give zero input to the arduino okay. And as you push this button, then the 5 volt will be given to the arduino. So normally you will say that your input is low and when you push the button, then your input will be high. Okay and you need to set this pin, whichever pin you are using to for for the to read the input signal. Also, there is another configuration which is pull up configuration which i have used as you can see. So in this configuration you need to connect the positive supply here with the resistor okay and then the the ground signal here. It is like this: okay, okay, so there is another uh configuration which is known as pull up configuration as you can see here. This one is my pull up configuration okay, so in pull up configuration, you need to connect this button with the ground, and this resistor is connected with pin number three and normally the signal is high. When you push the button, the signal goes to low. As you can see here, the blue, the blue signal, is actually showing you that your input becomes low when you push this button. Okay, so now my leds are actually functioning like if i switch. If i want to see the result on the oscilloscope so yeah, so this is the oscilloscope here so yeah so now see there is no signal on the leds, but as i push this button, you have the uh pwm okay.

So this is the same. Pw m signal which we have used in the previous video. Okay. Now my leds are flashing. So let me show you the program for that. So this is the software which i am using arduino ide and here is the program. So i think that i need to explain this program a little bit. So, first of all, what you need to do is is to define your pins, so i am using, pin number 10 and pin number 9 and pin number 11 okay. So these are my input. Pins which are providing input to the rgb leds, which are connected in common anode mode, then my input pin is connected to pin number three, and here i want to set the pin mode. So three pins are output, and the signal i am going to read is from the pin number three. So this will be my input pin and after that, what im going to do is im gon na read the status. What is given on the input? Pin number three and after that there is a while loop here, okay, so this while loop will activate when you push the button and you give a low signal when you give a low signal, then this for loop activate now this for loop is actually doing an Analog write to produce a square wave pwm to provide the leds so that they can change their brightness. So actually, this loop is divided into two parts.

First part is this one and when this loop finishes this loop starts, so we have the two loops okay. So this loop continues: if you it finds that you have the low input, then this loop will continue yeah. So here you can see that when you give push the button uh, your input will be low and when you release the button your input will be high. So when the high signal is activated so all of the leds will get ground signal and the leds are already connected with the positive 5 volt supply, so they will be permanently on right. So in this way, this circuit uh works, and you have already seen the simulation. So once again, i will show you so once you press this button, you now at this moment your input is your input is high. So when your input is high, your lights are on because they are getting the low signal from here and when you press this button now your input goes low and, according to the program, your leds will flash yeah. So this is the video which i want to show you and simulation now in a moment. I will also show you the actual hardware which i have used. Okay and i will run the hardware and show you the actual function of the flashing leds. Well guys. So this is the final uh demonstration for you, so i have connected my board with the computer and i have already uploaded the code.

So, as you can see now, my input is high because i havent pushed the button, so the leds are already on. So when i push this button now, the flashing program starts so leds are flashing now and when i release the button again, it will come back to its original state. So that is it, so i hope you like the video if you like, the video, give me a thumbs up and kindly subscribe to channel.