#include "pico/stdlib.h"
#include <math.h>
const uint ledPins[] = {0, 1, 2, 3};
const uint buttonPin = 15;
const int led_count = sizeof(ledPins) / sizeof(int);
const uint TSLEEP = 250;
volatile uint8_t counter = 0;
bool state = 0;
int main() {
gpio_init(buttonPin);
gpio_set_dir(buttonPin, GPIO_IN);
gpio_pull_up(buttonPin);
for (int i = 0; i < led_count; i++) {
gpio_init(ledPins[i]);
gpio_set_dir(ledPins[i], GPIO_OUT);
}
while (true) {
while (gpio_get(buttonPin) == 0) {
if (state = 1){
counter=1;
state = 0;
}
counter++;
sleep_ms(TSLEEP);
if (counter > 15) {
counter = 1;
}
for (int i = 0; i < led_count; i++) {
gpio_put(ledPins[i], 0);
}
}
state=1;
for (int i = 0; i < led_count; i++) {
gpio_put(ledPins[i], (counter >> i) & 0x01); //logisches und vergleich mit 0001
} // counter=13(1101); 1101 >> 0, = 1101 & 0001 = 0001; 1101 >> 1, x110 & 0001 = 0001; 1101 >> 2, xx11 & 0001 = 0001; 1101 >> 3, xxx1 & 0001 = 0001
} // insgesamte Ausgabe = On On Off On
}
//für meine klasse