Simple LED Test

by DanielZhu in Circuits > LEDs

108 Views, 0 Favorites, 0 Comments

Simple LED Test

thumbnail_PXL_20210510_015556746.jpg

at the start i want to make this project just like this, but the code make me give up, so I make it more simple as i can.

Step 1 - the Things You Need

thumbnail_PXL_20210510_015556746.jpg

this is the things you need

LED 10

Bread 1

USB cables 1

Buttons 1

Wire 14

Resistor 2

How It Looks Like

图片1.png

put them like the picture up there

Code

this is the code I used:

const int buttonPin = 13; int buttonState; void setup() { // put your setup code here, to run once: for (int i=1; i<14 ; i++){ pinMode(i, OUTPUT); pinMode(buttonPin, INPUT); Serial.begin(9600); }} void loop() { // put your main code here, to run repeatedly: buttonState = digitalRead(buttonPin); for (int i=1; i<14; i++){ digitalWrite(i,HIGH); digitalWrite(i-1,LOW); delay(500); if(buttonState==HIGH && i==6){ Serial.println("You Win"); } }}

Done

thumbnail_PXL_20210426_024440993.jpg

this is the project I made at start, if you think mine one is to easy you can try this one.