0% found this document useful (0 votes)
7 views5 pages

Assignment LED

This document outlines a project for VIII-grade students to control an LED using Arduino through digital blinking and analog fading techniques. It includes required components, circuit design, programming logic, and example codes for both LED blinking and fading. The objective is to help students understand Arduino basics and programming concepts while demonstrating practical applications of these techniques.

Uploaded by

Nandan Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

Assignment LED

This document outlines a project for VIII-grade students to control an LED using Arduino through digital blinking and analog fading techniques. It includes required components, circuit design, programming logic, and example codes for both LED blinking and fading. The objective is to help students understand Arduino basics and programming concepts while demonstrating practical applications of these techniques.

Uploaded by

Nandan Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

LED FADING CIRCUIT DESIGN

Class: VIII

Number of the Participants: 36

Duration: 40 MINUTE

Description:

Objective
The primary goal of this project is to demonstrate how to control an LED using both digital
and analog techniques on an Arduino.

●​ Blink an LED by switching it fully ON and OFF using digital functions.


●​ Create a fading effect by gradually changing the LED's brightness using Pulse Width
Modulation (PWM) with analog functions.

This documentation explains the code and the programming concepts—such as functions,
variables, loops, and specific functions like delay() and analogWrite()—to help you
understand the underlying logic.

​Circuit Design
Required Components:

●​ Breadboard
●​ Arduino Board
●​ LED
●​ Resistor (typically 220Ω or 330Ω)
●​ Wires

Connections:

●​ LED Blinking:
o​ Connect the LED (with a resistor in series) to digital pin 13.
o​ Connect the other end of the LED circuit to the Arduino's ground.







●​ LED Fading:
o​ Connect the LED (with a resistor in series) to analog pin 9 (which supports
PWM).
o​ Connect the other end of the LED circuit to the Arduino's ground
o​ Figure 2 showing Fading of LED

This setup allows you to test both the digital blinking and the analog fading techniques with
the same basic components by changing the connection pin as specified.

Programming Logic
[Link] Blinking-
Arduino IDE Code

●​ Functions:
o​ Definition: A function is a reusable block of code designed to perform a
specific task.
o​ Usage in Code:
▪​ setup(): Runs once when the program starts. It is used to initialize
settings (e.g., setting pin modes).
▪​ loop(): Runs repeatedly after setup(). Contains the main logic for
blinking the LED.
▪​ digitalWrite(): Sets a digital pin to HIGH (on) or LOW (off).
▪​ delay():
▪​ Definition: The delay() function pauses the program for a
specified number of milliseconds.
▪​ Usage: In our digital LED blinking code, delay(1000)
pauses the code for 1000 milliseconds (1 second) between
turning the LED ON and OFF, creating a visible blinking effect.

Logic:

1.​ Initialization: In the setup() function, the LED pin is defined as an OUTPUT.
2.​ Blinking Process: In the loop() function:
o​ Turn the LED ON using digitalWrite(LED_PIN, HIGH).
o​ Wait for one second using delay(1000).

o​ Turn the LED OFF using digitalWrite(LED_PIN, LOW).


o​ Wait for one second using delay(1000).
0.​ This cycle repeats indefinitely, causing the LED to blink.

2. LED Fading-
Arduino IDE Code

●​ Variables:
o​ Definition: A variable is a container for storing data values. Here, it holds the
brightness level.
●​ For Loops:
o​ Definition: A for loop executes a block of code a specified number of times.

Syntax:​

for (int i = 0; i < 10; i++)


{​
// Code executed 10 times​
}
●​ analogWrite():
o​ Definition: The analogWrite() function outputs a PWM signal, which can
simulate analog behavior by varying the duty cycle.
o​ Usage: In our code, analogWrite(LED_PIN, brightness) sets the
LED brightness according to the value of brightness (ranging from 0 to
255).

Logic:

1.​ Initialization: In the setup() function, set the LED pin (which supports PWM) as an
OUTPUT.
2.​ Fading Process: In the loop() function:
o​ Increasing Brightness: Use a for loop to increment a brightness variable
from 0 to 255. With each increment, update the LED brightness using
analogWrite(LED_PIN, brightness) and wait a short delay (e.g., 10
milliseconds) to make the change smooth.
o​ Decreasing Brightness: Use another for loop to decrement the
brightness variable from 255 to 0, again using analogWrite() with a
short delay after each change.
3.​ The LED gradually brightens and dims, creating a fading effect.

Code
Digital LED Blinking Code:-

// Digital LED Blinking Example​



// Define the LED pin​
const int LED_PIN = 13;​

void setup() {​
// Initialize the digital pin as an
output.​
pinMode(LED_PIN, OUTPUT);​
}​

void loop() {​
// Turn the LED on​
digitalWrite(LED_PIN, HIGH);​
// Pause for 1 second (1000 milliseconds)​
delay(1000);​

// Turn the LED off​
digitalWrite(LED_PIN, LOW);​
// Pause for 1 second (1000 milliseconds)​
delay(1000);​
}

Analog LED Fading Code:-

// Analog LED Fading Example​



// Define the PWM-capable LED pin​
const int LED_PIN = 9;​

void setup() {​
// Initialize the PWM pin as an output.​
pinMode(LED_PIN, OUTPUT);​
}​

void loop() {​
// Gradually increase brightness from 0 to 255​
for (int brightness = 0; brightness <= 255; brightness++)
{​
analogWrite(LED_PIN, brightness);​
delay(10); // Short delay for a smooth transition​
}​

// Gradually decrease brightness from 255 to 0​
for (int brightness = 255; brightness >= 0; brightness--)
{​
analogWrite(LED_PIN, brightness);​
delay(10); // Short delay for a smooth transition​
}​
}

Output
LED Blinking Output
●​ Observation: The LED (either the built-in one or an external LED connected to the
Arduino) will turn ON for one second and then OFF for one second continuously.
●​ Result: This produces a blinking effect where the LED is clearly visible turning on
and off at regular intervals.

LED Fading Output


●​ Observation: The LED will gradually increase its brightness from completely off (0)
to fully bright (255) and then gradually decrease back to off.
●​ Result: This creates a smooth fading effect, making the LED appear to "breathe" or
pulse gently.
o​ Usage: In our code, analogWrite(LED_PIN, brightness) sets the
LED brightness according to the value of brightness (ranging from 0 to
255).

Learning Outcomes; STUDENT WILL UNDERSTAND BASIC OF ARDINO UNO


MICROCONTROLLER AND ABLE TO USE IT.

Name of the teacher: NANDAN SINGH


Designation: TGT(WE)
Name of KV: PM SHRI KV ITBP MERTHI

You might also like