Skills Dev I- A simple Internet Appliance

Made by Darshil Shastri

I am creating my first IoT application by making a simple LED blink using the Argon microcontroller and building the code on particle

Created: November 2nd, 2023

0

Exercise 1.1- Make LED Blink on and off every 3 seconds.


The introduced code for the light blinking includes a loop that directs the light to illuminate (digitalWrite(ledPin, HIGH)) for a duration of three seconds (delay(3000)), followed by deactivation (digitalWrite(ledPin, LOW)) for an additional three seconds. As a result, the light alternates between on and off states at three-second intervals. 

Code and video are below

0
//setup variable

int led = D2;

void setup() {

 pinMode( led, OUTPUT );
 
}

void loop() {
    
    digitalWrite( led,HIGH );
    delay ( 3000 );
    
    digitalWrite( led,LOW );
    delay ( 3000 );
    
    //repeat and repeat and repeat
}
Click to Expand
0
0

Exercise 1.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)

 I modified the code by incorporating a nested loop within the loop() function to achieve five cycles of the light blinking on and off. Each blink is separated by a brief pause, and there's an additional 3-second delay after completing the five blinks.  

Code and video are below


0
//writing the code to make the LED blink every 3 seconds

// name and assign the pin

int led = D2;

void setup() {
//configure PIN to be an output pin

 pinMode( led, OUTPUT );
 
}

void loop() {

for(int i=0; i<5;i++)
{
    digitalWrite( led,HIGH );
    delay ( 500 );
    
    digitalWrite( led,LOW );
    delay ( 500 );
}

digitalWrite(led,LOW);
delay(3000);
    //repeat and repeat and repeat
}
Click to Expand
0
0

Exercise 1.3-  Go back to the original program. Now add a second LED to the circuit.   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.

I added another Led into the D3 input and then rewrote code 1, where I made them high and low alternatingly, with a small delay in between




0
int led1 = D2;
int led2 = D3;

void setup() {
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
}

void loop() {
    digitalWrite(led1, HIGH);
    digitalWrite(led2, LOW);
    delay(500);
    digitalWrite(led1, LOW);
    digitalWrite(led2, HIGH);
    delay(500);

}
Click to Expand
0
0

Reflection

Labelling the code helped me have a better understanding. Although I am still struggling with the concepts of loops, especially void loops, I think I can better comprehend writing basic code. My code can be longer, but it will get the job done!

x
Share this Project

Courses

48-675 Designing for the Internet of Things

· 11 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


Focused on
About

I am creating my first IoT application by making a simple LED blink using the Argon microcontroller and building the code on particle