Skip to main content

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);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500);
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(500);
digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500);
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(500);
}


I think you are having fun watching the output, pretty interesting right.

We can also generate other patterns like



Code for the above video.
// Pin 13 has a LED connected on most Arduino boards.

// give it a name:
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);
delay(500);
digitalWrite(led2, HIGH);
delay(500);
digitalWrite(led3, HIGH);
delay(500);
digitalWrite(led4, HIGH);
delay(800);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
delay(500);
}


So be innovative start developing your own logic, try this with 8 LEDs have fun.


What is the current sourcing and sinking?

Current sourcing means when our device (Arduino) acts as a source for the load.

Source Mode

Current sinking means when load is connected to a device so that current flows from the power supply through the load and into the device.

Sink Mode

Thinking?

To know more visit us at http://www.karkhana.club/

Comments

Popular posts from this blog

LED Brightness Control using Touch Sensor and ARM

Hey Folks, In this tutorial, we will learn, how to change  the intensity of light using touch sensor the ARM (FRDM-KL25Z). INTRODUCTION The FRDM-KL25Z is an ultra-low-cost development platform for Kinetis L Series KL1x (KL14/15) and KL2x (KL24/25) MCUs built on ARM® Cortex™-M0+ processor.  The FRDM-KL25Z has been designed by NXP in collaboration with mbed for prototyping all sorts of devices, especially those requiring the size and price point offered by Cortex-M0+ and the power of USB Host and Device. The FRDM-KL25Z is supported by a range of NXP and third-party development software. It is packaged as a development board with connectors to break out to stripboard and breadboard and includes a built-in USB FLASH programmer.               FEATURES NXP KL25Z Kinetis KL2x MCU (MKL25Z128VLK4) High-performance ARM® Cortex™-M0+ Core 48MHz, 16KB RAM, 128KB FLASH USB (Host/Device) SPI (2) I2C (2) UART (3) PWM (TPM) ...

Interfacing of Push Button With ATmega16

In this tutorial, we will learn how to interface a switch(push button) with ATMEGA16 using AVR studio. In the previous video, we learnt how to interface LEDs with ATMEGA16 using AVR studio. The push-button is a component that connects two points in a circuit when you press it. The example turns on an LED when you press the button. Here we have connected two push button to PORT C in  PC0 & PC1. And for LEDs connection please refer my previous blog. Components Required:- AVR Controller(Atmega16) LEDs Push Button Connecting Wires USBASP Programmer Dump the following code after connection  and select chip ATMEGA 16. #include<avr/io.h> #include<util/delay.h> void main()  {    DDRB=0b11111111;    int S1;    int S2;      while(1)    {     S1=PINC&0b00000001;     S2=PINC&0b00000010;     if(S1==0b00000001)     { ...

16x2 LCD Interfacing with Arduino

In this tutorial, we will learn, how to interface an LCD (liquid crystal display) with ARDUINO.  An LCD screen is an electronic display module having a flat panel display or we can say it’s an electronically modulated optical device that uses the light modulating properties of liquid crystals. We will interface a 16x2(16 columns and 2 rows) LCD. Other variations are also available like 8x1,10x2 etc. It is having a wide range of applications; they are also preferred over the 7-segment display as they are cheap, easily programmable and also have the leverage to display special characters. Now let us interface Components Required 16x2 LCD                   1No. Resistor 560ohms        1No. Potentiometer 10k      1No. Arduino UNO               1No. Few connecting wires Breadboard Follow the image below for circuit connection refe...