Skip to content
Snippets Groups Projects
Commit 9bb3fdef 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
fade.cpp 0 → 100644
#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);
for (i = 0; i < 255 < i++) {
//Set all Leds to Green
ledStrip.fill(WS2812::RGB(255 - i, i , 0));
ledStrip.show();
sleep_ms(counter);
}
for (i = 0; i < 255 < i++) {
//Set all LEDs to Cyan
ledStrip.fill(WS2812::RGB(0, 255, i));
ledStrip.show();
sleep_ms(counter);
}
for (i = 0; i < 255 < i++) {
//Set all LEDs to Blue
ledStrip.fill(WS2812::RGB(0, 255 - i, 255));
ledStrip.show();
sleep_ms(counter);
}
for (i = 0; i < 255 < i++) {
//Set all LEDs to Pink
ledStrip.fill(WS2812::RGB(i, 0, 255));
ledStrip.show();
sleep_ms(counter);
}
for (i = 0; i < 255 < i++) {
//Set all LEDs to Yellow
ledStrip.fill(WS2812::RGB(255, 0, 255 - i));
ledStrip.show();
sleep_ms(counter);
}
}
}
\ 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