This gist was automatically pasted at the request of 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
January 26, 2021 13:34
-
-
Save ArduinoDiscordBot/96599cd7ac454156cd7a1461ece41b9c to your computer and use it in GitHub Desktop.
Code by anTon#1337 - Tue Jan 26 2021 13:34:21 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
``` | |
// Include the Neopixel library | |
#include <Adafruit_NeoPixel.h> | |
// Declare and initialise global GPIO pin constant for Neopixel ring | |
const byte neoPin = 10; | |
// Declare and initialise global constant for number of pixels | |
const byte neoPixels = 24; | |
// Declare and initialise variable for Neopixel brightness | |
byte neoBright = 200; | |
// Create new Neopixel ring object | |
Adafruit_NeoPixel ring = Adafruit_NeoPixel(neoPixels, neoPin, NEO_GRB); | |
void setup() { | |
Serial.begin(9600); | |
pinMode(2, INPUT_PULLUP); | |
// Initialise the ring | |
ring.begin(); | |
ring.setBrightness(neoBright); | |
ring.show(); | |
} | |
void loop() { | |
int sensorVal = digitalRead(2); | |
Serial.printIn(sensorVal); | |
if(sensorVal == HIGH) { | |
digitalWrite(13, LOW) | |
} | |
else{ | |
digitalWrite(13, HIGH); | |
} | |
// Turn on pixels | |
for(int i = 0; i < neoPixels; i++){ | |
ring.setPixelColor(i, ring.Color(0,118,189)); | |
ring.show(); | |
delay(1000); | |
ring.setPixelColor(i, ring.Color(0,0,0)); | |
ring.show(); | |
delay(1000); | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment