Skip to content
Snippets Groups Projects
Commit 56fc661b authored by ajk1e20's avatar ajk1e20
Browse files

Upload New File

parents
No related branches found
No related tags found
No related merge requests found
#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include "pico/binary_info.h"
#include "WS2812.hpp"
const uint BUTTON_SPEED_UP = 20;
const uint BUTTON_SLOW_DOWN = 21;
const uint ON_OFF_BUTTON = 22;
const uint RGB = 28;
uint counter = 50;
int main() {
stdio_init_all();
//Initialize the LED Strip using ledStrip in WS2812 in Git
WS2812 ledStrip(
RGB,
1,
pio0,
0
);
//Add button to slow down
while (!gpio_get(BUTTON_SLOW_DOWN)) {
counter = counter + 50;
}
//add button to speed up
while (!gpio_get(BUTTON_SPEED_UP)) {
if (counter > 50) {
counter = counter - 50;
}
}
while (!gpio_get(ON_OFF_BUTTON)) {
//Add colours you wish to display in your
//Set all LEDs to Red
ledStrip.fill(WS2812::RGB(255, 0, 0));
ledStrip.show();
sleep_ms(counter);
//Set all Leds to Green
ledStrip.fill(WS2812::RGB(0, 255, 0));
ledStrip.show();
sleep_ms(counter);
//Set all LEDs to Cyan
ledStrip.fill(WS2812::RGB(0, 255, 255));
ledStrip.show();
sleep_ms(counter);
//Set all LEDs to Blue
ledStrip.fill(WS2812::RGB(0, 0, 255));
ledStrip.show();
sleep_ms(counter);
//Set all LEDs to Yellow
ledStrip.fill(WS2812::RGB(255, 0, 0));
ledStrip.show();
sleep_ms(counter);
//Set all LEDs to Pink
ledStrip.fill(WS2812::RGB(255, 0, 255));
ledStrip.show();
sleep_ms(counter);
}
//Add on off buttons
/*
while (true) {
// Pick a random color
uint32_t color = (uint32_t)rand();
// Pick a random direction
int8_t dir = (rand() & 1 ? 1 : -1);
// Setup start and end offsets for the loop
uint8_t start = (dir > 0 ? 0 : LED_LENGTH);
uint8_t end = (dir > 0 ? LED_LENGTH : 0);
for (uint8_t ledIndex = start; ledIndex != end; ledIndex += dir) {
ledStrip.setPixelColor(ledIndex, color);
ledStrip.show();
sleep_ms(50);
}
}
*/
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment