Experiment diverse operations of LED blinking by setting up basic Particle circuit and programming simple codes.
0
Process
1. Setting up Particle circuit.
2. Connecting the circuit with cloud.
3. Writing codes on the Particle platform.
4. Send data to the Particle board.
5. Observation and experiment!
0
Reflection
It was my first time to make circuit. Just like I firstly started programming, the process was full of wonders. It was so amazing that this simple electric device does what I ordered. At first, I had difficulty understanding coding convention is different from general programming. This is because I learned global variable is really bad thing. But, in Particle context, making a global variable was crucial to make things happen.
0
Exercise 1. Modify the program to Blink on and off every 3 seconds.
0
int ledPin = D2;
void setup() {
// We want to tell the Argon that we'll use
// D2 as an output pin.
pinMode(ledPin, OUTPUT);
}
void loop() {
// led on for 3 sec
digitalWrite(ledPin, HIGH);
delay(3000);
// led sleep for 3 sec
digitalWrite(ledPin, LOW);
delay(3000);
}
Click to Expand
0
Exercise 2. Change the program to blink on and off 5 times then stop for 3 seconds.
0
int ledPin = D2;
void setup() {
// We want to tell the Argon that we'll use
// D2 as an output pin.
pinMode(ledPin, OUTPUT);
}
void loop() {
// blink 5 times for 0.5 sec
int i = 0;
while (i < 5) {
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
i ++;
}
// sleep for 3 sec
digitalWrite(ledPin, LOW);
delay(3000);
}
Click to Expand
0
Exercise 3. Program the LED’s to alternate blinks
0
int ledPin1 = D2;
int ledPin2 = D3;
void setup() {
// D2 and D3 as output pins
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop() {
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
delay(1000);
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin2,HIGH);
delay(1000);
}