#include <gpio_viewer.h> // Must be the first include in your project
GPIOViewer gpio_viewer;
// Define the pins for each segment
int segmentPinsRight[] = {32, 33, 25, 26, 27, 14, 12};
int segmentPinsLeft[] = {5, 17, 16, 4, 0, 2, 15};
// Define the segments for each number
int numbers[][7] = {
{1, 1, 1, 1, 1, 1, 0}, // 0
{0, 1, 1, 0, 0, 0, 0}, // 1
{1, 1, 0, 1, 1, 0, 1}, // 2
{1, 1, 1, 1, 0, 0, 1}, // 3
{0, 1, 1, 0, 0, 1, 1}, // 4
{1, 0, 1, 1, 0, 1, 1}, // 5
{1, 0, 1, 1, 1, 1, 1}, // 6
{1, 1, 1, 0, 0, 0, 0}, // 7
{1, 1, 1, 1, 1, 1, 1}, // 8
{1, 1, 1, 1, 0, 1, 1} // 9
};
void setup() {
gpio_viewer.connectToWifi("Wokwi-GUEST", "");
Serial.begin(9600); //serial start and pin config
// Set the segment pins as OUTPUT
for (int i = 0; i < 7; i++) {
pinMode(segmentPinsRight[i], OUTPUT);
pinMode(segmentPinsLeft[i], OUTPUT);
}
gpio_viewer.begin();
Serial.println("Setup Complete");
}
void loop() {
//Display numbers 0 to 9
for (int num = 0; num < 10; num++) {
displayNumberRight(num);
displayNumberLeft(num);
Serial.print("Displaying Number: ");
Serial.print(num);
Serial.println();
delay(1000); // Display each number for one second
}
}
void displayNumberRight(int num) {
// Display the segments for the given number
for (int i = 0; i < 7; i++) {
digitalWrite(segmentPinsRight[i], numbers[num][i]);
}
}
void displayNumberLeft(int num) {
// Display the segments for the given number
for (int i = 0; i < 7; i++) {
digitalWrite(segmentPinsLeft[i], numbers[num][i]);
}
}
void displayNumber(int num) {
if (num < 0 || num > 99) {
return;// Handle error: number out of range
}
displayNumberLeft(num / 10);
displayNumberRight(num % 10);
}