Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #define LED_PIN 6
- #define WIDTH 16
- #define HEIGHT 16
- #define NUM_LEDS (WIDTH * HEIGHT)
- CRGB leds[NUM_LEDS];
- int index(int x, int y) {
- if (y % 2 == 0)
- return y * WIDTH + WIDTH - x - 1;
- else
- return y * WIDTH + x;
- }
- int bail_x = 0;
- int bail_y = 0;
- int bail_vx = 0;
- int bail_vy = 0;
- int player_1 = 0;
- int player_2 = 0;
- int MAX_BR = 255;
- int X_pos = 1;
- int X_pos_2 =WIDTH-2 ;
- int palca = 3;
- #define rezistor_1 A0
- #define rezistor_2 A1
- void setup() {
- Serial.begin(115200);
- FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS);
- FastLED.setBrightness(50);
- pinMode(rezistor_1, INPUT);
- pinMode(rezistor_2, INPUT);
- }
- void loop() {
- player_1 = map(analogRead(rezistor_1), 0, 1023, 0, HEIGHT - palca + 1);
- player_2 = map(analogRead(rezistor_2), 0, 1023, 0, HEIGHT - palca + 1);
- for (int i = 0; i < palca; i++) {
- leds[index(X_pos, i + player_1)].setRGB(0, 0, MAX_BR);
- }
- for (int i = 0; i < palca; i++) {
- leds[index(X_pos_2, i + player_2)].setRGB(MAX_BR, 0,0 );
- }
- FastLED.show();
- for (int i = 0; i < palca; i++) {
- leds[index(X_pos, i + player_1)].setRGB(0, 0, 0);
- }
- for (int i = 0; i < palca; i++) {
- leds[index(X_pos_2, i + player_2)].setRGB(0, 0, 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement