#include <Arduino.h>
#include <U8x8lib.h>
U8X8_SSD1306_128X64_ALT0_HW_I2C oled(/* reset=*/ U8X8_PIN_NONE);
void setup(void) {
oled.begin();
oled.setFlipMode(0);
}
void loop(void) {
int soundLevel = analogRead(A2);
if ( soundLevel > 400 )
{ int reply = random(8);
oled.setFont(u8x8_font_chroma48medium8_r);
oled.clear();
// set the cursor to column 0, line 0
oled.setCursor(0, 0);
// print some text
oled.print("the ball says:");
// move the cursor to the second line
oled.setCursor(0, 1);
// choose a saying to print based on the value in reply
switch (reply) {
case 0:
oled.print("Yes");
break;
case 1:
oled.print("Most likely");
break;
case 2:
oled.print("Certainly");
break;
case 3:
oled.print("Outlook good");
break;
case 4:
oled.print("Unsure");
break;
case 5:
oled.print("Ask again");
break;
case 6:
oled.print("Doubtful");
break;
case 7:
oled.print("No");
break;
}
}
delay(50);
}