#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
//declaring the function
void cyclone(uint8_t valu);
void printbin8(uint8_t valu);
//calling the definition function
void dec();
//creating an array to declare the pins
int LEDs[8] = { 47, 48, 45, 0, 35, 36, 37, 38};
//defining the gpio pins
void app_main() {
uint8_t count = 0b00000001;
dec();
while (1) {
cyclone(count);
}
}
/*function name- printbin8
description - prints out the binary value in a for loop
return type- returns nothing
parameters-valu
*/
//defining the function
void printbin8(uint8_t valu) {
for (int i = 7; i >= 0; i--) {
//prints the current value
printf("%u", (valu >> i) & 1);
}
}
void dec() {
for (int w = 7; w >= 0; w--) {
//setting the directions
gpio_set_direction(LEDs[w], GPIO_MODE_OUTPUT);
}
}
void
cyclone(uint8_t count) {
for (int i = 0; i < 7; i++) {
printf("The value of %d in binary is: 0b", count);
printbin8(count);
printf("\n");
// 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));
}
for (int j = 0; j < 7; j++) {
printf("The value of %d in binary is: 0b", count);
printbin8(count);
printf("\n");
// 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));
}
}