Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #define LED_PIN 6
- #define BRIGHTNESS 255
- #define LED_TYPE WS2811
- #define COLOR_ORDER RGB
- const uint8_t kMatrixWidth = 10;
- const uint8_t kMatrixHeight = 4;
- const bool kMatrixSerpentineLayout = true;
- int prognumber = 1;
- int K1 = 13;
- int K2 = 12;
- int K3 = 11;
- int K4 = 10;
- int buttonState = 0;
- #define NUM_LEDS (kMatrixWidth * kMatrixHeight)
- #define MAX_DIMENSION ((kMatrixWidth>kMatrixHeight) ? kMatrixWidth : kMatrixHeight)
- // The leds
- CRGB leds[kMatrixWidth * kMatrixHeight];
- // The 16 bit version of our coordinates
- static uint16_t x;
- static uint16_t y;
- static uint16_t z;
- uint16_t speed = 20; // speed is set dynamically once we've started up
- uint16_t scale = 30; // scale is set dynamically once we've started up
- // This is the array that we keep our computed noise values in
- uint8_t noise[MAX_DIMENSION][MAX_DIMENSION];
- CRGBPalette16 currentPalette( PartyColors_p );
- uint8_t colorLoop = 1;
- //=====================================================================================
- void setup() {
- delay(3000);
- LEDS.addLeds<LED_TYPE,LED_PIN,COLOR_ORDER>(leds,NUM_LEDS);
- LEDS.setBrightness(BRIGHTNESS);
- pinMode(K1, INPUT);
- pinMode(K2, INPUT);
- pinMode(K3, INPUT);
- pinMode(K4, INPUT);
- digitalWrite(K1, HIGH);
- digitalWrite(K2, HIGH);
- digitalWrite(K3, HIGH);
- digitalWrite(K4, HIGH);
- pinMode(LED_PIN, OUTPUT);
- //Activate key pin internal pull-up resistors
- Serial.begin(9600);
- // Initialize our coordinates to some random values
- x = random16();
- y = random16();
- z = 0;
- }
- //=======================================================================================
- void loop() {
- buttonState = digitalRead(K1);
- if(!buttonState)Serial.print("k1 \n" );
- do
- {
- buttonState = digitalRead(K1);
- lampon();
- }
- while(!buttonState);//Wait button release
- buttonState = digitalRead(K2);
- if(!buttonState)Serial.print("k2 \n" );
- do
- {
- buttonState = digitalRead(K2);
- lampoff();
- }
- while(!buttonState);//Wait button release
- }
- void lampon() {
- for(int all = 0; all < NUM_LEDS; all++) {
- leds[all] = CHSV( 0, 0, 255);
- FastLED.show();
- }
- }
- void lampoff() {
- for(int all = 0; all < NUM_LEDS; all++) {
- leds[all] = CHSV( 0, 0, 0);
- FastLED.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment