Skills Dev III: Ambient Orb-Hongyu Mao

Made by Hongyu Mao

In this exercise, I followed up with the tutorial and finally made a device connect to Google Calendar and it will give me an ambient notification for a new update of the event.

Created: December 15th, 2021

0

Outcome

    • In this exercise, I followed up with the tutorial and finally made a device connect to Google Calendar and it will give me an ambient notification for a new update of the event.
0

Exercise 1: Light Up neopixel and then Turn Off

The first step I test the neopixel to see if it could be light up one by one and turn off, I follow up with the course instruction and code.

0
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

#include "neopixel.h"

// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D2
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

void setup()
{
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}
void loop()
{

   for(int i=0; i<strip.numPixels(); i++) {
     strip.setPixelColor(i, 255, 0, 0 );
     strip.show();
     delay(1000);
   }

    delay(1000) ;
    
   for(int i=0; i<strip.numPixels(); i++) {
     strip.setPixelColor(i, 0, 0, 0 );
     strip.show();
     delay(1000);
   }



}
Click to Expand
0

Exercise 2: Light Up neopixel  by one

The Led of neopixel will light up by one, and each time only one Led will work on. I change the content of the for loop.

0
nclude <neopixel.h>

#include "neopixel.h"

#define PIXEL_PIN D2
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812
 
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);



void setup() {

  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}



void loop() {

  uint16_t i;

  for(i=0; i< strip.numPixels(); i++) {
    strip.setPixelColor(i, 0,255,255 );
    strip.show();
	delay( 200 );
	strip.setPixelColor(i, 0, 0, 0 );
  }

}
Click to Expand
0
skill dev 3.1
Hongyu Mao - https://www.youtube.com/watch?v=yCYfSggho6s
0

Exercise 3: Add 3 particle function to set the R G B value


0
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

#include "neopixel.h"
#define PIXEL_PIN D2
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812
 
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int red = 0;
int green = 0;
int blue = 0;


void setup() {

  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  Particle.function("R", setRed);
  Particle.function("G", setGreen);
  Particle.function("B", setBlue);
}



void loop() {

  uint16_t i;

  for(i=0; i< strip.numPixels(); i++) {
    strip.setPixelColor(i, red, green, blue);//blue
	//strip.setPixelColor(i, 0, 0, 0 );
  }
   strip.show();
// 	delay( 1000 );

}

int setRed(String command){
    int number = atoi(command);
    if(number >=0 && number <= 255){
        red = number;
    }
    return red;
}

int setGreen(String command){
    int number = atoi(command);
    if(number >=0 && number <= 255){
        green = number;
    }
    return green;
}

int setBlue(String command){
    int number = atoi(command);
    if(number >=0 && number <= 255){
        blue = number;
    }
    return blue;
}
Click to Expand
0

Exercise 4: combine with IFTTT


0
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

#include "neopixel.h"
#define PIXEL_PIN D2
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812
 
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int red = 0;
unsigned long lastFade = 0;
int redPercentage=255;
// bool goingRed = true;
int goingRed = 1;


void setup() {

  strip.begin();
  strip.show(); 
  Particle.function("Red", setRed);

}


void loop() {
    
    
	unsigned long now = millis();
    if(red == 1){
	    
	    if ((now - lastFade) >= 500) {
            if (goingRed == 1) {
    			redPercentage = redPercentage - 2.5; 
    // 			Particle.publish("It is going red now");
    			if(redPercentage <= 0){
    			    redPercentage = 0;
    			    goingRed = 0;
    			}
    		}
    		
    		else if(goingRed == 0) {
    		    redPercentage = redPercentage + 2.5;
    		  //  Particle.publish("It is going white now");
    		    if(redPercentage >= 255){
    		        redPercentage = 255;
    		        goingRed = 1;
    		        red = 0;
    		    }
    	    }
    	
            lastFade=now;
    
        }
        
	
    }
    
    for(uint16_t i=0; i < strip.numPixels(); i++) {
            strip.setPixelColor(i, 255, redPercentage, redPercentage);
    }
	
	strip.show();
}
	
  
int setRed(String command){
    int number = atoi(command);
    if(number == 1){
        red = 1;
    }
    return red;
}
Click to Expand
0
x
Share this Project

Courses

About

In this exercise, I followed up with the tutorial and finally made a device connect to Google Calendar and it will give me an ambient notification for a new update of the event.