Skills Dev 1 -Amal

Made by Amal Jafrani

Skills Dev1

Created: November 10th, 2021

0

Outcome

The goal of this skill dev was to begin working with LED's and turning multiple on, making them blink, or doing it through the cloud. Videos are submitted on Canvas.

0
int led1 = D3;
int led2 = D2;

void setup() {

pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}

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

// for( int i = 0; i < 3; i++ )
// 	{
// 	    digitalWrite(led1, HIGH);
//         delay(500);
//         digitalWrite(led1, LOW);
//         delay(500);
// 	}
// delay(3000);

digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
delay(1000);
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
delay(1000);






}
Click to Expand
0
int led1 = D3;
int led2 = D2;

void setup() {

pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);

digitalWrite(led1, LOW);
digitalWrite(led2, LOW);

Particle.function("led1", led1Control);
Particle.function("led2", led2Control);


}

void loop() {

}


// int led1Control(String command)
// {
//   int state = LOW;

//   // find out the state of the led
//   if(command == "HIGH"){
// 	   for (int e = 0; e < 4; e++){        
//             digitalWrite(led1, HIGH);
//             delay(500);
//             digitalWrite(led1, LOW);
//             delay(500);
// 	    }
//   }else if(command == "LOW"){ 
// 	   state = LOW;
//   }else{
// 	   return -1;
//   }
//   return 1;

//   // write to the appropriate pin
//   digitalWrite(led1, state);
//   return 1;
// }

// int led1Control(String command){
//     int number = atoi(command);
//         for(int e=0; e<number; e++){
//             digitalWrite(led1, HIGH);
//             delay(500);
//             digitalWrite(led1, LOW);
//             delay(500);
//     }
//     return 1;
// }

int led1Control(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(led1, state);
   return 1;
}

int led2Control(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(led2, state);
   return 1;
}
Click to Expand
0

Reflection

The first 3 tasks were pretty straight forward as they did not involve working with the cloud, but when I began to work with the cloud I encountered some issues. I initially tried to work through the command prompt, but I was getting a lot of errors there, so I switched to sending commands through the website and that worked a lot smoother for me. Additionally, my particle keeps going offline, so that is something I would want to figure out by the next skill dev.

x