Skills Dev III _xuyangj
Made by Xuyang Jin · UNLISTED (SHOWN IN POOLS)
Made by Xuyang Jin · UNLISTED (SHOWN IN POOLS)
To create an ambient calendar alert using a neopixel strip.
Created: November 24th, 2020
This week, we have learnt how to deal with neopixel and I would like to connect the device to Google Calendar through IFTTT eventually. I start from some small practice to light up the neopixel in different ways.
#include <neopixel.h>
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D3
#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;
uint32_t c = strip.Color(255, 255, 255);
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, c );
strip.show();
delay( 100 );
}
for(i=strip.numPixels(); i> 0; i--) {
strip.setPixelColor(i, 0 );
strip.show();
delay( 100 );
}
delay( 100 );
}
Click to Expand
#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() {
uint16_t i;
uint32_t c1 = strip.Color(0, 0, 255);
uint32_t c2 = strip.Color(255, 0, 0);
uint32_t c3 = strip.Color(0, 255, 0);
uint32_t c4 = strip.Color(255, 255, 255);
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, c1 );
strip.show();
delay( 100 );
}
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, c2 );
strip.show();
delay( 100 );
}
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, c3 );
strip.show();
delay( 100 );
}
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, c4 );
strip.show();
delay( 100 );
}
delay( 100 );
}
Click to Expand
#include <neopixel.h>
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D3
#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;
uint32_t c = strip.Color(255, 255, 255);
for(i=0; i >= 0 ; i++) {
if (i == 15){
strip.setPixelColor(0, c );
strip.setPixelColor(i, 0 );
i = i - 16;
strip.show();
delay( 100 );
}else{
strip.setPixelColor(i+1, c );
strip.setPixelColor(i, 0 );
strip.show();
delay( 100 );
}}
}
Click to Expand
#include <neopixel.h>
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D3
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
long timeAtParticleFuction = 0;
long turnOffAfter = 15*60*1000;
bool lightStatus = false;
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
Particle.function("turnOn", turnOn );
Particle.function("turnOff", turnOff );
}
int turnOn(String command)
{
lightStatus = true;
timeAtParticleFuction = millis();
return 0;
}
int turnOff(String command)
{
lightStatus = false;
timeAtParticleFuction = millis();
return 0;
}
void loop() {
uint16_t i;
uint32_t cred = strip.Color(255, 0, 0);
uint32_t cwhite = strip.Color(255, 255, 255);
if(lightStatus == true){
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, cred );
}
strip.show();
}else{
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, cwhite );
}
strip.show();
}
}
Click to Expand
This project is really interesting. It is good to know how to connect other applications through IFTTT to my circuit. This is the first time that I felt like even the simple connected circuit could help our life and the design doesn't have to be too complex to put into practice. And this really inspired me to further design on IoT to make more simple circuits for practical use.
IFTTT is really useful because it provide quite a lot opportunities to make connections. I would like to try more on it.