Skills Dev III: Ambient Orb_Yulin
Made by Yulin Chen ·
Made by Yulin Chen ·
Created: November 13th, 2024
Create a simple connection and display between Neopixels and meeting in google calendar by particle and IFTTT.
It is very interesting to build the connection between these as a meeting alert. At first, it is a little bit hard for me to understand the millis(), so I just follow the instruction to do this part. I try two version of code to do this, maybe the first one has somewhere wrong, sometimes it can perform well but sometimes doesn't, however, I verified it in particle it shows correct.
#include "Particle.h"
#include <neopixel.h>
#define PIXEL_PIN SPI
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812B
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
unsigned long lastFade = 0;
int Interval = 9000;
int brightness = 0;
bool com = true;
void setup() {
strip.begin();
strip.show();
Particle.function("LightUp", handleHandleLightUp);
}
int handleHandleLightUp(String command) {
com = true;
return 1;
}
void loop() {
if (com) {
unsigned long now = millis();
uint16_t i;
uint32_t c = strip.Color(255, 255, 255);
if ((now - lastFade) >= Interval) {
for (int color = 255; color > 0; color--) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
uint32_t c = strip.Color(255, color, color);
strip.setPixelColor(i, c);
}
strip.show();
delay(20);
}
lastFade = now;
}
com = false;
} else if (!com) {
unsigned long now = millis();
if ((now - lastFade) >= Interval) {
for (int color = 0; color <= 255; color++) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
uint32_t c = strip.Color(255, color, color);
strip.setPixelColor(i, c);
}
strip.show();
delay(20);
}
lastFade = now;
}
com = true;
}
}
Click to Expand
#include "Particle.h"
#include <neopixel.h>
#define PIXEL_PIN SPI
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812B
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
unsigned long lastFade = 0;
int Interval = 9000;
int brightness = 0;
bool com = true;
void setup() {
strip.begin();
strip.show();
Particle.function("LightUp", handleHandleLightUp);
}
int handleHandleLightUp(String command) {
unsigned long now = millis();
uint16_t i;
uint32_t c = strip.Color(255, 255, 255);
if ((now - lastFade) >= Interval) {
for (int color = 255; color > 0; color--) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
uint32_t c = strip.Color(255, color, color);
strip.setPixelColor(i, c);
}
strip.show();
delay(20);
}
lastFade = now;
}
for (int color = 0; color <= 255; color++) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
uint32_t c = strip.Color(255, color, color);
strip.setPixelColor(i, c);
}
strip.show();
delay(20);
}
lastFade = now;
return 1;
}
Click to Expand
This project is only accessible by signed in users. Be considerate and think twice before sharing.
~