0% found this document useful (0 votes)
39 views3 pages

Lab 6

The document contains two Arduino programs for controlling 10 LEDs. The first program makes the LEDs blink sequentially from the 1st to the 10th and back, while the second program fades the LEDs in and out by adjusting their brightness. Both programs utilize loops and delay functions to achieve the desired LED effects.

Uploaded by

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

Lab 6

The document contains two Arduino programs for controlling 10 LEDs. The first program makes the LEDs blink sequentially from the 1st to the 10th and back, while the second program fades the LEDs in and out by adjusting their brightness. Both programs utilize loops and delay functions to achieve the desired LED effects.

Uploaded by

hacsp2107
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

4.

1: Program to make 10 LEDs blink from 1st to 10th and vice


versa
#define LED_COUNT 10

int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};

void setup() {

for (int i = 0; i < LED_COUNT; i++) {

pinMode(ledPins[i], OUTPUT);

void loop() {

// Blink from 1st to 10th LED

for (int i = 0; i < LED_COUNT; i++) {

digitalWrite(ledPins[i], HIGH);

delay(100);

digitalWrite(ledPins[i], LOW);

// Blink from 10th to 1st LED

for (int i = LED_COUNT - 1; i >= 0; i--) {

digitalWrite(ledPins[i], HIGH);

delay(100);

digitalWrite(ledPins[i], LOW);

4.2: Program to fade 10 LEDs:


#define LED_COUNT 10

int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};

void setup() {

for (int i = 0; i < LED_COUNT; i++) {

pinMode(ledPins[i], OUTPUT);

void loop() {

// Fade in

for (int brightness = 0; brightness <= 255; brightness++) {

for (int i = 0; i < LED_COUNT; i++) {

analogWrite(ledPins[i], brightness);

delay(10);

// Fade out

for (int brightness = 255; brightness >= 0; brightness--) {

for (int i = 0; i < LED_COUNT; i++) {

analogWrite(ledPins[i], brightness);

delay(10);

You might also like