This gist was automatically pasted at the request of the code author or one of the discord server helpers. If you have any suggestions or bugs to report, you can do so on our GitHub repository, or in our discord server. This project is run by volunteers so feel free to fork and commit your changes then open a pull request!
Created
December 27, 2020 23:15
-
-
Save ArduinoDiscordBot/e28a59f9b69936d72d93cf3138a18425 to your computer and use it in GitHub Desktop.
Code by Unseen#7064 - Sun Dec 27 2020 23:15:03 GMT+0000 (Coordinated Universal Time)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c++ | |
// Motion sensor led's programmed by myself \\ | |
// Version: BETA \\ | |
// Creation date: 26/12/2020 \\ | |
// Info: N/A \\ | |
#include <FastLED.h> | |
#define LED_PIN 5 | |
#define NUM_LEDS 150 | |
#define BRIGHTNESS 0 // MAXIMUM IS 255 -- default is 65 | |
#define LED_TYPE WS2811 | |
#define COLOR_ORDER GRB | |
CRGB leds[NUM_LEDS]; | |
bool activated = ""; | |
int ledPin = 13; // LED | |
int pirPin = 7; // PIR Out pin | |
int pirStat = 0; // PIR status | |
void setup() { | |
//delay(3000); // power-up safety delay -- Uneeded as of now | |
FastLED.addLeds < LED_TYPE, LED_PIN, COLOR_ORDER > (leds, NUM_LEDS).setCorrection(TypicalLEDStrip); | |
FastLED.setBrightness(0); | |
FastLED.show(); | |
pinMode(ledPin, OUTPUT); | |
pinMode(pirPin, INPUT); | |
Serial.begin(9600); | |
delay(500); // ORIGINAL IS 1000 | |
} | |
void loop() { | |
pirStat = digitalRead(pirPin); | |
if (pirStat == HIGH) { // if motion detected | |
activated = true; | |
Serial.println("I'VE DETECTED MOTION"); | |
Serial.println(activated); | |
delay(500); // uneeded delay??s | |
} else { | |
if (pirStat == LOW) { // if no motion detected | |
activated = false; | |
Serial.println("No motion detected"); | |
Serial.println(activated); | |
delay(500); | |
} | |
} | |
if (activated == true) { | |
FastLED.setBrightness(65); | |
for (int i = 0; i < NUM_LEDS; i++) { | |
leds[i] = CRGB(255, 192, 203); // 50, 255, 20 | |
} | |
FastLED.show(); | |
} else { | |
if (activated == false) { | |
FastLED.setBrightness(0); | |
FastLED.show(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment