Skip to main content

Posts

Showing posts with the label Sudolearn

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                                  

LED Pattern with Arduino

Alright since now we know how to interface a LED let’s have some fun generating patterns with multiple LED. Components Required Resistor                    4 No. 330Ohms(Standard Red LED and 5V input supply) LEDs                        4 No. Arduino UNO          1No. Connecting wires Breadboard In this blog, we have generated a shifting glowing pattern of LEDs. For circuit, connections see below After building the circuit dump the code given below. int led1 = 1; int led2 = 2; int led3 = 3; int led4 = 4; void setup()  { pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); } void loop() { digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW delay(500); digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW delay(500); d

Getting Started with LED's

Now since we know how an Arduino works let us have some fun with the board. For those of you who are new kindly have a look at the link given below. http://sudolearn.blogspot.com/2017/05/getting-started-with-arduino.html Let us first design a smart led blinking system which will blink how we want it to, sounds fun right. So let’s begin Components Required Resistor                        1No.  330ohms (Standard Red LED and 5V Input) Led                               1No. Arduino UNO              1No. Few Connecting wires Breadboard Follow the below video for circuit connection reference: Now since we have made the circuit let us do the coding part // declare the pin to which LED is connected: int led = 5;  //The below is the setup block the part which we want to run only once we declare them in this block void setup() // initialize the digital pin as an output. { pinMode(led, OUTPUT); } void loop() //The code we write inside void loop