#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <stdint.h>
#include "driver/gpio.h"
//array for all LEDS and pins
int LEDS[8] = {38, 37, 36, 35, 0, 45, 48, 47};
//creating the function to turn integer numbers into binary notation using uint8_t
void cylon(uint8_t valu) {
//printing the integer in binary
printf("The value of %u in binary is: 0b", valu); // Use %u for uint8_t
// Loop through each bit from Most to left which ends at 255
for (int i = 7; i >= 0; i--) {
printf("%d", (valu >> i) & 1); // Shift and mask to get the bit
}
printf("\n"); // adding a new line after every number
}
void app_main() {
uint8_t count = 1;
for (int i = 0; i < LCOUNT; i++) {
}
while (1) {
cylon(count);
}
// Code Segment 2.1
while (1) {
uint8_t count = 0b00000001; // Start with first LED on
// Move left (shifting left)
for (int i = 0; i < 7; i++) {
printf("The value of %d in binary is: 0b", count);
cylon(count);
printf("\n");
gpio_set_direction(LEDS[i], GPIO_MODE_OUTPUT);
// Update LED bargraph
for (int k = 0; k < 8; k++) {
gpio_set_level(LEDS[k], (count >> k) & 1);
}
count <<= 1; // Shift left
vTaskDelay(pdMS_TO_TICKS(300));
}
// Move right
// Add your code here
}
}