Skills Dev III : Yashasvi
Made by ytulchiy · UNLISTED (SHOWN IN POOLS)
Made by ytulchiy · UNLISTED (SHOWN IN POOLS)
To create an ambient calendar alert using a neopixel strip.
Created: November 27th, 2020
To create an ambient calendar alert using a neopixel strip
// This #include statement was automatically added by the Particle IDE.
#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 c = strip.Color(255, 255, 255);
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, c );
strip.show();
delay( 100 );
}
delay( 100 );
}
Ready.Last Event: particle/device/updates/pending = false yashasvi_14 v1.5.2
Click to Expand
// This #include statement was automatically added by the Particle IDE.
#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 c = strip.Color(0, 0, 255);
uint32_t d = strip.Color(255, 0, 0);
uint32_t e = strip.Color(0, 128, 0);
uint32_t f = strip.Color(255, 255, 255);
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, c );
strip.show();
delay( 100 );
}
delay( 100 );
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, d );
strip.show();
delay( 100 );
}
delay( 100 );
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, e );
strip.show();
delay( 100 );
}
delay( 100 );
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, f );
strip.show();
delay( 100 );
}
delay( 100 );
}
Click to Expand
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D2
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812
Adafruit_NeoPixel light_ring = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
bool lightStatus = false;
void setup() {
light_ring.begin();
light_ring.show(); // Initialize all pixels to 'off'
Particle.function("sync-on",turnOn);
Particle.function("sync-off",turnOff);
}
int turnOn(String command)
{
lightStatus = true;
return 0;
}
int turnOff(String command)
{
lightStatus = false;
return 0;
}
void loop(){
if(lightStatus == true){
for(int i=0; i<light_ring.numPixels(); i++){
light_ring.setPixelColor(i,255,0,0); //red
}
light_ring.show();
}else{
for(int i=0; i<light_ring.numPixels(); i++){
light_ring.setPixelColor(i,255,255,255); //white
}
light_ring.show();
}
}
Click to Expand
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D2
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812
Adafruit_NeoPixel light_ring = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int brightness = 0;
unsigned long timeAtParticleFunction = 0;
unsigned long timeFade = 30*1000;
bool lightStatus = false;
void setup() {
light_ring.begin();
light_ring.show();
Particle.function("sync-on",turnOn);
Particle.function("sync-off",turnOff);
}
int turnOn(String command)
{
lightStatus = true;
timeAtParticleFunction = millis();
return 0;
}
int turnOff(String command)
{
lightStatus = false;
timeAtParticleFunction = millis();
return 0;
}
void loop(){
if(lightStatus == true){
// for(int i=0; i<light_ring.numPixels(); i++){
// light_ring.setPixelColor(i,255,0,0); //red
// }
// light_ring.show();
unsigned long timeNow = millis();
if( timeAtParticleFunction + timeFade < timeNow ){
// lightStatus = false;
// this will step up the brightness from 255 to 0
for( int brightness = 255; brightness > 0; brightness++ ){
// loop over each led and set the brightness
for( int i = 0; i < light_ring.numPixels(); i++ ){
light_ring.setPixelColor( i, brightness, 0 , 0 );
}
light_ring.show();
delay( 100 );
}
}
}else{
for(int i=0; i<light_ring.numPixels(); i++){
light_ring.setPixelColor(i,255,255,255); //white
}
light_ring.show();
}
}
Click to Expand