#include <secrets.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(128, 64);
// Define site-password pairs
const char* sites[] = {"Site1", "Site2", "Site3"};
const char* passwords[] = {"Password1", "Password2", "Password3"};
const int numSites = 3; // The number of sites
int selectedSite = 0;
// Define pin numbers for buttons
const int scrollButtonPin = 0; // Replace with the actual pin numbers you use
const int selectButtonPin = 1; // Replace with the actual pin numbers you use
void setup() {
Serial.begin(115200);
secrets.begin("PicoW Password");
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
secrets.begin();
delay(5000);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0, 0);
display.print("Welcome!");
display.display();
// Initialize button pins
pinMode(scrollButtonPin, INPUT_PULLUP);
pinMode(selectButtonPin, INPUT_PULLUP);
}
void loop() {
// Read button states
bool scrollButtonState = digitalRead(scrollButtonPin);
bool selectButtonState = digitalRead(selectButtonPin);
// Scroll through menu options
if (scrollButtonState == LOW) {
selectedSite = (selectedSite + 1) % numSites;
delay(200); // Button debounce
}
// Select the current menu option
if (selectButtonState == LOW) {
// Perform the action associated with the selected site (e.g., send a password)
// This part of the code needs to be added as per your requirements.
// For simplicity, you can print the site name for now.
Serial.println("Selected: " + String(sites[selectedSite]));
delay(200); // Button debounce
}
// Display site menu
display.clearDisplay();
display.setCursor(40, 0);
for (int i = 0; i < numSites; i++) {
if (i == selectedSite) {
display.setTextColor(BLACK, WHITE);
display.print(">");
} else {
display.setTextColor(WHITE);
display.print(" ");
}
display.print(sites[i]);
display.println();
}
display.display();
}