From the course: Learning Arduino: Interfacing with Hardware
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Cycle through LEDs with a for loop - Arduino Tutorial
From the course: Learning Arduino: Interfacing with Hardware
Cycle through LEDs with a for loop
- So in the previous video, we kind of copy and paste a lot of the code so let's try to use a for loop in order to reduce the code that we tried in the previous example. Since we did the wiring for the Arduino board, from two all the way to eight, so we can take advantage of using a for loop where we can start from two all the way to eight. So let's see how we can do that in the coding parts. So I'll give it a start in here. On line 13 all the way to line 19, the only thing that's being changed is the LED parts. So you notice here it's A, B, C, D. So since we do the wiring from two all the way to eight, so we can use a for loop. So in the for loop, I'm going to go ahead and initialize a starting point. I'll name it equals to two because the pins are connected from two. And then I is less than nine because I want the number to stop at eight. And then finally the increment would be just one. Now inside the for loop, I…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Overview of the 7-segment LED35s
-
(Locked)
The 7-segment LED component1m 24s
-
(Locked)
7-segment LED display types1m 42s
-
(Locked)
Checking a 7-segment LED type1m 32s
-
(Locked)
Wiring up the 7-segment LED4m 50s
-
(Locked)
Cycle through each LED directly5m 34s
-
(Locked)
Cycle through LEDs with a for loop2m 29s
-
(Locked)
Understanding the 7-segment LED truth table2m 7s
-
(Locked)
Coding 7-segment display showing numbers3m 21s
-
-
-
-