Skills Dev I: LED BLINK

Made by Yulin Chen · UNLISTED (SHOWN IN POOLS)

The project tends to create an interesting moment that the LED’s to alternate blinks.

Created: November 1st, 2024

0

Intention

I want to get to know some basic logic of IoT programming through these three exercises.

0

Process

For the first and second one, I follow the logic of Loop to control the status of LED. For the third exercise, at first the second LED was not worked, I tried many times to adjust my code, finally, I found it was because the jumper wire put in the wrong place (front of the second LED)

0

Reflection

Now I just finish these three basic skill tests, I got to know how to use the loop logic and how to control two LED through the code. Maybe I will try to use multiple methods and add more sensors to control the blink of LED like the sound, the temperature, or some other interesting things.

0

Exercise 1: 

Modify the program to Blink on and off every 3 seconds.  

0
int ledPin1 = D2;
void setup(){
    pinMode(ledPin1,OUTPUT);
}

void loop(){
    digitalWrite(ledPin1,HIGH);
    delay(3000);
    
    digitalWrite(ledPin1,LOW);
    delay(3000);
}
Click to Expand
0

Exercise 2:   

Change the program to blink on and off 5 times then stop for 3 seconds. Each blink should be 0.5s (a half second)  

0
int ledPin1 = D2;
void setup(){
    pinMode(ledPin1,OUTPUT);
}

void loop(){
    for (int i = 0; i < 5; i++){
        
        digitalWrite(ledPin1,HIGH);
        delay(500);
    
        digitalWrite(ledPin1,LOW);
        delay(500);
    }
    delay(3000);
}
Click to Expand
0

Exercise 3:     

Program the LED’s to alternate blinks i.e. when LED 1 turns on, LED 2 turns off, then when LED 2 turns on, LED 1 turns off.  

0
int ledPin1 = D2;
int ledPin2 = D1;

void setup(){
    pinMode(ledPin1,OUTPUT);
    pinMode(ledPin2,OUTPUT);
    
}

void loop(){
    for (int i = 0; i < 5; i++){
        
        digitalWrite(ledPin1,HIGH);
        digitalWrite(ledPin2,LOW);
        delay(500);
    
        digitalWrite(ledPin2,HIGH);
        digitalWrite(ledPin1,LOW);
        delay(500);
    }
    digitalWrite(ledPin2,LOW);
    delay(3000);
}
Click to Expand
x
Share this Project

This project is only listed in this pool. Be considerate and think twice before sharing.



Focused on
About

The project tends to create an interesting moment that the LED’s to alternate blinks.