Narayan - Skills Dev III: Ambient Orb

Made by Narayan Ashanahalli

The goal of the object to control an electroic though online data though IFTTT

Created: November 20th, 2024

0
// Include the Particle-compatible NeoPixel library
#include <neopixel.h>

// Set the pixel COUNT, PIN, and TYPE
#define PIXEL_PIN SPI // WIRE TO PIN MO
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812B

Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

bool notificationActive = false; // Tracks if the notification is active
unsigned long notificationStart = 0;
unsigned long notificationDuration = 900000; // 15 minutes in milliseconds

int startNotification(String command) {
    notificationActive = true;
    notificationStart = millis();
    return 1; // Return success
}

void setup() {
    strip.begin();
    strip.show();
    Particle.function("startAlert", startNotification); // Cloud function
}

void loop() {
    if (notificationActive) {
        unsigned long elapsed = millis() - notificationStart;

        if (elapsed <= notificationDuration) {
            int brightness = map(elapsed, 0, notificationDuration, 0, 255);
            for (int i = 0; i < PIXEL_COUNT; i++) {
                strip.setPixelColor(i, strip.Color(brightness, 0, 0)); // Red fade
            }
            strip.show();
        } else {
            notificationActive = false; // Reset after duration
        }
    }
}
Click to Expand
0
x
Share this Project


About

The goal of the object to control an electroic though online data though IFTTT