Isha Hans - Ambient Orb
Made by ihans
Made by ihans
Create an ambient calendar alert using a neopixel strip
Created: November 17th, 2021
// This #include statement was automatically added by the Particle IDE.
#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();
}
void loop() {
strip.show();
uint16_t i;
uint32_t c = strip.Color(0, 0, 255); // Blue
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, c); // set a color
strip.show();
delay( 200 );
}
}
Click to Expand
// This #include statement was automatically added by the Particle IDE.
#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 numPixels = strip.numPixels();
void setup() {
strip.begin();
strip.show();
}
void loop() {
uint16_t i;
uint32_t c1 = strip.Color(0, 0, 255); // Blue
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, c1); // set a color
strip.show();
delay( 200 );
}
uint32_t c2 = strip.Color(0, 0, 0); //turning off by removing color
for( int i = numPixels; i >0; i-- ){
strip.setPixelColor(i, c2); // set a color
strip.show();
delay( 200 );
}
}
Click to Expand
// This #include statement was automatically added by the Particle IDE.
#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 numPixels = strip.numPixels();
void setup() {
strip.begin();
strip.show();
}
void loop() {
uint16_t i;
uint32_t c1 = strip.Color(0, 0, 255); // Blue
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, c1); // set a color
strip.show();
delay( 100 );
}
uint32_t c2 = strip.Color(0, 0, 0); //turning off by removing color
for( int i = numPixels; i >0; i-- ){
strip.setPixelColor(i, c2); // set a color
strip.show();
delay( 100 );
}
uint32_t c3 = strip.Color(0, 255, 0); // Blue
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, c3); // set a color
strip.show();
delay( 100 );
}
for( int i = numPixels; i >0; i-- ){
strip.setPixelColor(i, c2); // set a color
strip.show();
delay( 100 );
}
uint32_t c4 = strip.Color(255, 0, 0); // Blue
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, c4); // set a color
strip.show();
delay( 100 );
}
for( int i = numPixels; i >0; i-- ){
strip.setPixelColor(i, c2); // set a color
strip.show();
delay( 100 );
}
}
Click to Expand
// This #include statement was automatically added by the Particle IDE.
#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 numPixels = strip.numPixels();
void setup() {
strip.begin();
strip.show();
}
void loop() {
uint16_t i;
uint32_t c1 = strip.Color(240, 230, 70); // Blue
uint32_t c2 = strip.Color(0, 0, 0); //turning off by removing color
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, c1); // set a color
strip.show();
delay( 400 );
strip.setPixelColor(i, c2); // set a color
strip.show();
delay( 400 );
}
}
Click to Expand
// This #include statement was automatically added by the Particle IDE.
#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();
Particle.function("tomato", setRed);
Particle.function("spinach", setGreen);
Particle.function("blueberry", setBlue);
}
void loop() {
}
int setRed(String f){ //functions for particle.function start with an int and take only string commands
int rValue = f.toInt(); //first:convert string to number
uint32_t red = strip.Color(rValue, 0, 0); //second: use the newly converted int to define color
uint16_t i;
for (i=0; i < strip.numPixels(); i++){
strip.setPixelColor(i, red);
strip.show();
}
delay(500);
return 1;
}
int setGreen(String f){ //functions for particle.function start with an int and take only string commands
int gValue = f.toInt(); //first:convert string to number
uint32_t green = strip.Color(0, gValue, 0); //second: use the newly converted int to define color
uint16_t i;
for (i=0; i < strip.numPixels(); i++){
strip.setPixelColor(i, green);
strip.show();
}
delay(500);
return 1;
}
int setBlue(String f){ //functions for particle.function start with an int and take only string commands
int bValue = f.toInt(); //first:convert string to number
uint32_t blue = strip.Color(0, 0, bValue); //second: use the newly converted int to define color
uint16_t i;
for (i=0; i < strip.numPixels(); i++){
strip.setPixelColor(i, blue);
strip.show();
}
delay(500);
return 1;
}
Click to Expand
Exercise 6: Create an ambient calendar alert using a Neopixel strip to send an alert to my device a few minutes before an appointment.
I broke this apart into pieces as advised on the website and first learnt how to work with mills()in order to change color from red to blue. It took me multiple attempts and many hours to understand the syntax, I'm still not an expert but I think I understand the logic of syntax better thanks to this struggle.
// This #include statement was automatically added by the Particle IDE.
#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);
unsigned long lastUpdateValue = 0;
int brightness = 255;
uint16_t i;
uint32_t w = strip.Color(255, 255, 255); // soft white
void setup() {
strip.begin();
strip.show();
Particle.function("tomato", setRed);
// Particle.function("spinach", setGreen);
// Particle.function("blueberry", setBlue);
}
void loop() {
strip.show();
if(w == 255) {
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, w); // set a color
}
}else{
unsigned long timeNow = millis();
if((timeNow-lastUpdateValue) >=1000){
if(brightness > 0){
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, brightness, 0, 255-brightness); //shifting color over a period of time
}
strip.show();
brightness = brightness-10;
lastUpdateValue = timeNow;
}
}
}
}
Click to Expand
int setRed(String f){ //functions for particle.function start with an int and take only string commands
int rValue = f.toInt(); //first:convert string to number
uint32_t red = strip.Color(rValue, 0, 0); //second: use the newly converted int to define color
uint16_t i;
for (i=0; i < strip.numPixels(); i++){
strip.setPixelColor(i, red);
strip.show();
}
delay(500);
return 1;