Assignment 3

3x3 LED Grid

 

The objective of the assignment to create groups of two and create a grid of 9 leds and spell names our names out. To this, we learnt basic arduino programing for LED. Using the Arduino UNO that we have we started by creating multiple circuits for control over each individual LED. Metioned below are the components we need to build this setup:

Material required

 



visual



Procedure



Arduino Codes used

Initialising the ports for the specific LEDs and Buttons:

int led = 1;

...

int led9 = 9;

int buttonApin = 11;

int buttonApin = 12;

 

Setting up the digital pins as outputs:

void setup() {

pinMode(led, OUTPUT);

...

pinMode(led9, OUTPUT);

pinMode(buttonApin, INPUT_PULLUP); 
pinMode(buttonBpin, INPUT_PULLUP);

Serial.begin(9600);
}

Note: - pinMode() configures the specified pin to behave either as an input or an output. Serial.begin(9600) sets the data rate in bits per second (baud) for serial data transmission.

 

Creating the loop routine:

1. First operation of lettering the name with buttonA:

void loop() {

if (digitalRead(buttonApin) == LOW)
{
Serial.println("Button A Pressed");

 

//H
Serial.print("H");

digitalWrite(led, HIGH); 
digitalWrite(led2, HIGH); 
digitalWrite(led3, HIGH); 
digitalWrite(led5, HIGH); 
digitalWrite(led7, HIGH); 
digitalWrite(led8, HIGH); 
digitalWrite(led9, HIGH); 
delay(2000); 

digitalWrite(led, LOW); 
digitalWrite(led2, LOW); 
digitalWrite(led3, LOW); 
digitalWrite(led5, LOW); 
digitalWrite(led7, LOW); 
digitalWrite(led8, LOW); 
digitalWrite(led9 , LOW); 
delay(1000);

 

In this loop, specific LEDs are turned on with the digitalWrite() function and turned off with the same using HIGH and LOW outputs.

The serial monitor output is also provided with Serial.println() to print and move to next line or Serial.print() to print and continue on the same line.

 

2.Blinking all the LEDs at delay(1000) five times:

if (digitalRead(buttonBpin) == LOW)
{

for (int x = 0; x < 5; x++)

{

digitalWrite(led, HIGH); 
digitalWrite(led2, HIGH); 
digitalWrite(led3, HIGH); 
digitalWrite(led4, HIGH); 
digitalWrite(led5, HIGH); 
digitalWrite(led6, HIGH); 
digitalWrite(led7, HIGH); 
digitalWrite(led8, HIGH);
digitalWrite(led9, HIGH); 
delay(1000);

}

}

Using a for() loop to repeat the code until it reaches 5 times and then stops.

 

 


LED

Showing me and my teammates name as - 

HI GEO
YO ISH

The LEDs blink to reveal our name over a 3x3 pattern.


The Final result