Skip to main content

Posts

Showing posts with the label Patterns

Getting Started with Switches

Since now we are well acquainted with LED’s let us learn how to control the switching using a push button. In this tutorial, we will learn how to use a push button. A push button is used to get control of the circuit. Components Required Resistors                           2Nos. 330ohms,10k(recommended) Pushbutton                        1No. LED                                  1No. Standard red LED Arduino UNO Breadboard Follow the video to make the circuit. After making the circuit it will look like Now dump the code given below int d=2; // chose the pin which you have connected to the output of push button void setup() { pinMode(2,INPUT); pinMode(13,OUTPUT); } void loop() { d=digitalRead(2); if(d==0) { digitalWrite(13,HIGH); } else { digitalWrite(13,LOW); } } Now the control is in your hands whenever you will press the button the led will be ON and when you release it, LED will go OFF. You can alter the control like