#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
int buttonPin = 2;
// Number of words in each category
int verbCount = 8;
int nounCount = 10;
int pronounCount = 6;
int adverbCount = 6;
int adjectiveCount = 6;
int prepositionCount = 4;
int conjunctionCount = 4;
// Arrays of words in each category
String verbs[] = {"run", "jump", "fly", "dance", "sing", "swim", "write", "paint"};
String nouns[] = {"cat", "dog", "bird", "tree", "flower", "car", "book", "computer", "phone", "desk"};
String pronouns[] = {"I", "you", "he", "she", "we", "they"};
String adverbs[] = {"quickly", "slowly", "eagerly", "happily", "sadly", "angrily"};
String adjectives[] = {"happy", "sad", "angry", "big", "small", "tall"};
String prepositions[] = {"in", "on", "at", "with"};
String conjunctions[] = {"and", "but", "or", "so"};
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setCursor(0, 0);
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.println("Welcome!");
display.display();
delay(1000);
display.clearDisplay();
}
void loop() {
if (digitalRead(buttonPin) == LOW) {
display.clearDisplay();
display.setCursor(0, 0);
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.println(getRandomSentence());
display.display();
delay(1000);
}
}
String getRandomSentence() {
String pronoun = getRandomWord(pronouns, pronounCount);
String verb1 = getRandomWord(verbs, verbCount);
String adverb1 = getRandomWord(adverbs, adverbCount);
String conjunction1 = getRandomWord(conjunctions, conjunctionCount);
String pronoun2 = getRandomWord(pronouns, pronounCount);
String verb2 = getRandomWord(verbs, verbCount);
String preposition = getRandomWord(prepositions, prepositionCount);
String adjective = getRandomWord(adjectives, adjectiveCount);
String noun = getRandomWord(nouns, nounCount);
return pronoun + " " + verb1 + " " + adverb1 + ", " + conjunction1 + " " + pronoun2 + " " + verb2 + " " + preposition + " the " + adjective + " " + noun + ".";
}
String getRandomWord(String words[], int count) {
int randomIndex = random(count);
return words[randomIndex];
}