Lesson 98-7: Walking Light Using Arduino and 5 LEDs
In this lesson we learn how to use LED and Push button in this 10 LED projects. Wiring diagram is shown, code is fully explained and demonstrated with multiple change of settings for each project. We read potentiometer's voltage and display voltage by turning each LED on to represent voltages. A Simple traffic light project. This code is part of video lecture. This project 7 code. this is an Arduino sktech where 4 LEDS turn ON and OFF in such a way that an LED is walking.
427-Lesson 98: Arduino 10 LED Push-Button Projects, Potentiometer LED Voltmeter, and Traffic Light
语言: C++
/*
* Arduino Step by Step Course by Robojax
* Lesson 98 https://robojax.com/course1/?vid=lecture98
* Project 7 of 10
*
* 4 LEDs walking light Arduino Project
* This is an Arduino sketch where 4 LEDs turn ON and OFF in such a way
* that an LED is walking
* Watch full details and demonstration: https://youtu.be/OSwleCBlkuI
*
* Start a full Arduino Step By Step course: https://youtu.be/-6qSrDUA5a8
*
* * LED = Light Emitting Diode
* LED is pronounced (El EE Dee)
****** 10 Projects explained in this video
* 1-LED ON OFF
* 2-LED ON/OFF with push button
* 3-LED ON/OFF toggle with push button
* 4-Fading light of LED
* 5-Fading light of LED using push button
* 6-See Saw with LED
* 7-Walking Light
* 8-Walking light with push button
* 9-LED voltage level meter
* 10- Arduino Traffic Light
*
* Written by Ahmad Shamshiri on Feb 01, 2022
* This code can be obtained from Robojax.com
* Code ID: WalkingLED
This video is part of Arduino Step by Step Course which starts here: https://youtu.be/-6qSrDUA5a8
* www.Robojax.com
If you found this tutorial helpful, please support me so I can continue creating
content like this. Make a donation using PayPal by credit card https://bit.ly/donate-robojax
* This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.*
* This code has been downloaded from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.*
*/
const int LED1 = 3;
const int LED2 = 4;
const int LED3 = 5;
const int LED4 = 6;
const int LED5 = 7;
int offTime = 30;//the time LED waits in OFF state
int onTime = 100;//the time LED is ON
//the code inside setup() runs once.
void setup() {
pinMode(LED1, OUTPUT);//set pin of Arduino as output
pinMode(LED2, OUTPUT);//set pin of Arduino as output
pinMode(LED3, OUTPUT);//set pin of Arduino as output
pinMode(LED4, OUTPUT);//set pin of Arduino as output
pinMode(LED5, OUTPUT);//set pin of Arduino as output
}//setup end
void loop() {
digitalWrite(LED1, HIGH);//set pin 2 to HIGH
delay(onTime); //wait for the onTime seconds (see top of this code)
digitalWrite(LED1, LOW); // Set pin 2 to LOW
delay(offTime); //wait for the offTime seconds (see top of this code)
digitalWrite(LED2, HIGH); //set pin 3 to HIGH
delay(onTime); //wait for the onTime seconds (see top of this code)
digitalWrite(LED2, LOW); // Set pin 3 to LOW
delay(offTime); //wait for the offTime seconds (see top of this code)
digitalWrite(LED3, HIGH); //set pin 4 to HIGH
delay(onTime); //wait for the onTime seconds (see top of this code)
digitalWrite(LED3, LOW); // Set pin 4 to LOW
delay(offTime); //wait for the offTime seconds (see top of this code)
digitalWrite(LED4, HIGH); //set pin 5 to HIGH
delay(onTime); //wait for the onTime seconds (see top of this code)
digitalWrite(LED4, LOW); // Set pin 5 to LOW
delay(offTime); //wait for the offTime seconds (see top of this code)
digitalWrite(LED5, HIGH); //set pin 6 to HIGH
delay(onTime); //wait for the onTime seconds (see top of this code)
digitalWrite(LED5, LOW); // Set pin 6 to LOW
delay(offTime); //wait for the offTime seconds (see top of this code)
// Watch full details and demonstration: https://youtu.be/7xTHaFdCyaI
}
资源与参考
尚无可用资源。
文件📁
没有可用的文件。