Skills Dev I: A Simple Internet Appliance - pgt

Made by pgomezte

Created: November 2nd, 2022

0

Based on the lab from last Thursday, I built a circuit board using the Argon Particle, 1 LEDs and 2 wires. 

After completing the setup, I connected my Argon to my home WiFi using the Particle app on my mobile phone.

Circuit board is shown below

0


The code shown below connects the device to the cloud, where the user (me) can direct the Argon to turn the light on and off with two commands: HIGH and LOW. High will turn the LED light on and Low will turn the LED light off

0
// name the pins
int ledPin = D2;

void setup() {

   // Configure the pins to be outputs
   pinMode(ledPin, OUTPUT);

   // Initialize both the LEDs to be OFF
   digitalWrite(ledPin, LOW);

   //Register our Particle function here
   Particle.function("led", ledControl);
}

void loop() {

}

int ledControl(String command)
{
   int state = LOW;

   // find out the state of the led
   if(command == "HIGH"){
	   state = HIGH;
   }else if(command == "LOW"){ 
	   state = LOW;
   }else{
	   return -1;
   }

   // write to the appropriate pin
   digitalWrite(ledPin, state);
   return 1;
}
Click to Expand
0

Using the cloud console from particle (screenshot below), I can call the device to turn the light on. The image below shows the result of such command

0

Using the same command line, but typing LOW allows me to turn the LED light off.

x