/ NeoPixel_GoPro_Lens_Light / NeoPixel_GoPro_Lens_Light.ino
NeoPixel_GoPro_Lens_Light.ino
1 // SPDX-FileCopyrightText: 2018 Limor Fried for Adafruit Industries 2 // 3 // SPDX-License-Identifier: MIT 4 5 #include <Adafruit_NeoPixel.h> 6 #ifdef __AVR__ 7 #include <avr/power.h> 8 #endif 9 10 #define PIN 0 //neopixel pin 11 12 int POT = A1; //analog pin 1 = Trinket m0 Pin 2 13 int val = 0; 14 15 // Parameter 1 = number of pixels in strip 16 // Parameter 2 = Arduino pin number (most are valid) 17 // Parameter 3 = pixel type flags, add together as needed: 18 // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 19 // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) 20 // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) 21 // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) 22 // NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) 23 Adafruit_NeoPixel ring = Adafruit_NeoPixel(16, PIN, NEO_RGBW + NEO_KHZ800); 24 25 void setup() { 26 ring.begin(); 27 ring.setBrightness(255); //max brightness available for the pot 28 ring.show(); // Initialize all pixels to 'off' 29 } 30 31 void loop() { 32 val = analogRead(POT); //will hold analog value sent by pot 33 val = map(val, 0, 1023, 0, 255); //maps analog values to digital so that it can be used by the neopixel 34 35 uint16_t i; 36 37 //sets all 16 pixels to on and only show level of white light defined by analog value of the pot 38 for (i = 0; i < ring.numPixels(); i++) { 39 ring.setPixelColor(i, 0, 0, 0, val); 40 } 41 ring.show(); 42 }