Skill Dev1- Chengzhi Zhang

Made by Chengzhi Zhang ·

Skill Dev 1 in IoT

Created: November 12th, 2021

0
int ledPin = D2;

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  digitalWrite(ledPin, HIGH);
  delay(3000);       
  digitalWrite(ledPin, LOW);
  delay(3000);   

}
Click to Expand
0
SkillDev1.1
Chengzhi Zhang - https://youtu.be/nk8ZuO898Ek
0
int ledPin = D2;

void setup() {
    pinMode(ledPin, OUTPUT);
    
}

void loop() {

    for (int e = 0; e < 5; e++) {        
        digitalWrite(ledPin, HIGH);
        delay(500);
        digitalWrite(ledPin, LOW);
        delay(500);
    }
    
    delay(3000);

}
Click to Expand
0
SkillDev1.2
Chengzhi Zhang - https://youtu.be/kqeea6o0DEw
0
int ledPin1 = D2;
int ledPin2 = D3

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

void loop() {
  digitalWrite(ledPin1, HIGH);
  delay(3000);       
  digitalWrite(ledPin1, LOW);
  delay(3000);   
  digitalWrite(ledPin2, HIGH);
  delay(3000);       
  digitalWrite(ledPin2, LOW);
  delay(3000);   

}
Click to Expand
0
SkillDev1.3
Chengzhi Zhang - https://youtu.be/IZj3XHaMtWA
0
int ledPin = D2;

void setup()
{
   pinMode(ledPin, OUTPUT);
   digitalWrite(ledPin, LOW);
   Particle.function("led", ledControl);
}
void loop()
{
   // Nothing to do here
}
int ledControl(String command)
{
   int state = LOW;

   if(command == "HIGH"){
       for(int i = 0; i < 3; i++){
           digitalWrite(ledPin, HIGH);
           delay(500);
           digitalWrite(ledPin, LOW);
           delay(500);
       }
   }else if(command == "LOW"){ 
	   state = LOW;
   }else{
	   return -1;
   }

   digitalWrite(ledPin, state);
   return 1;
}
Click to Expand
0
SkillDev1.4
Chengzhi Zhang - https://youtu.be/frWDxa5FsMM
0
int ledPin = D2;

void setup()
{
   pinMode(ledPin, OUTPUT);
   digitalWrite(ledPin, LOW);
   Particle.function("led", ledControl);
}
void loop()
{
   // Nothing to do here
}
int ledControl(String command)
{
   int state = LOW;
   int num = command.toInt();
    for(int i = 0; i < num; i++){
           digitalWrite(ledPin, HIGH);
           delay(500);
           digitalWrite(ledPin, LOW);
           delay(500);
   }

   digitalWrite(ledPin, state);
   return 1;
}
Click to Expand
0
SkillDev1.5
Chengzhi Zhang - https://youtu.be/0m5CwZ1KhWM
0
int ledPin1 = D2;
int ledPin2 = D3;

void setup()
{
   pinMode(ledPin1, OUTPUT);
   pinMode(ledPin2, OUTPUT);
   digitalWrite(ledPin1, LOW);
   digitalWrite(ledPin2, LOW);
   Particle.function("led1", ledControl);
   Particle.function("led2", ledControl);
}
void loop()
{
   // Nothing to do here
}
int ledControl(String command)
{
   int state = LOW;

   if(command == "HIGH"){
       for(int i = 0; i < 3; i++){
           digitalWrite(ledPin, HIGH);
           delay(500);
           digitalWrite(ledPin, LOW);
           delay(500);
       }
   }else if(command == "LOW"){ 
	   state = LOW;
   }else{
	   return -1;
   }

   digitalWrite(ledPin, state);
   return 1;
}
Click to Expand
0
SkillDev1.6
Chengzhi Zhang - https://youtu.be/sHDbh5XPi0Y
0

Outcome

    • The outcomes are demonstrated  in the videos. I've also attached the source code for reference.
0

Process

I spent a night working on skilldev1. Much more time than I expected for the skillDev1. I spent a lot of time in exercise 1, and it happened to be that my light bulb is not working, no wonder! I used visual studio to organize my codes before pasting each of these into the particle website and run them before recording the videos. 

0

Reflection

1. With for function, you can determine how many times you blink the light, while you may not combine it with the existing "while" function for determining whether the light should be "ON" or "OFF". It's a little trick here. 

2. I used the num function for turning the function input into numbers. You should use google to find out what function is needed if the current ones do not work. CPP is quite different with python in this way.

3. Sometimes, although all the codes are right, they just don't work. And you should just spend more time and give it more shots by trying again and again.

4. For physical prototyping, unlike only using computer for programming, you have one more thing to check- your circuit! I spent two hours checking the simple code finding out it's my light bulb that's not working. So, we should be careful with all the stuff.

5. Gallery page is just so hard to use! UI is SOOO important!

6. I'll use less resolution to record videos next time. The file size is too big..

0
x
Share this Project

This project is only accessible by signed in users. Be considerate and think twice before sharing.


Courses

About

Skill Dev 1 in IoT