Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "PinChangeInterrupt.h"
- #include <Adafruit_NeoPixel.h>
- // constants won't change. They're used here to
- // set pin numbers:
- int wait = 20;
- const int ledPin = 6; // the number of the neopixel strip
- const int numLeds = 37;
- int jasnosc = 50;
- bool tryb;
- //Adafruit_NeoPixel pixels = Adafruit_NeoPixel(8, ledPin);
- Adafruit_NeoPixel strip = Adafruit_NeoPixel(numLeds, ledPin, NEO_GRB + NEO_KHZ800);
- #define gora 12
- #define menu 11
- #define dol 10
- void setup() {
- Serial.begin(9600);
- pinMode(12, INPUT_PULLUP); //gora
- pinMode(11, INPUT_PULLUP); //menu
- pinMode(10, INPUT_PULLUP); //dol
- strip.begin();
- strip.setBrightness(50);
- attachPCINT(digitalPinToPCINT(gora), goraf, FALLING);
- attachPCINT(digitalPinToPCINT(menu), menuf, FALLING);
- attachPCINT(digitalPinToPCINT(dol), dolf, FALLING);
- }
- void goraf(){
- if(jasnosc<250){
- jasnosc=jasnosc+10;
- }
- Serial.print("gora ");
- strip.setBrightness(jasnosc);
- Serial.println(jasnosc, DEC);
- }
- void menuf(){
- Serial.println("menu");
- Serial.print(tryb);
- tryb = !tryb;
- wait = 0;
- }
- void dolf(){
- if(jasnosc>0){
- jasnosc=jasnosc-10;
- }
- Serial.print("dol ");
- strip.setBrightness(jasnosc);
- Serial.println(jasnosc, DEC);
- }
- uint32_t Wheel(byte WheelPos) {
- if(WheelPos < 85) {
- return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
- }
- else if(WheelPos < 170) {
- WheelPos -= 85;
- return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
- }
- else {
- WheelPos -= 170;
- return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
- }
- }
- void loop() {
- if(tryb){
- strip.setBrightness(jasnosc);
- Serial.println("tryb rgb");
- wait = 20;
- rainbow();
- }
- else
- {
- int i;
- for(i=0; i < numLeds; i++ ) {
- strip.setBrightness(jasnosc);
- strip.setPixelColor(i,255,255,255);
- }
- strip.show();
- }
- strip.show();
- }
- void rainbow() {
- uint16_t i, j;
- for(j=0; j<256; j++) {
- for(i=0; i<strip.numPixels(); i++) {
- strip.setBrightness(jasnosc);
- strip.setPixelColor(i, Wheel((i*1+j) & 255));
- }
- strip.show();
- delay(wait);
- }
- }
- // Input a value 0 to 255 to get a color value.
- // The colours are a transition r - g - b - back to r.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement