Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- OLED disp(SDA, SCL, 8);
- extern uint8_t SmallFont[];
- const int bp0 = 7; //A
- const int bp1 = 6; //Б
- const int x = 0;
- const int y = 0;
- int bs0 = LOW;
- int bs1 = LOW;
- void setup() {
- disp.begin();
- disp.setFont(SmallFont);
- pinMode(bp0, INPUT_PULLUP);
- pinMode(bp1, INPUT_PULLUP);
- }
- void loop() {
- bs0 = digitalRead(bp0);
- bs1 = digitalRead(bp1);
- Serial.println(bs0);
- Serial.println(bs1);
- if (question==0) {
- question = 1 + (rand() % static_cast<int>(5 - 1 + 1));
- disp.clrScr();
- disp.print(String(question),x,y);
- disp.update();
- }
- if (bs0==HIGH) {
- checkAnsver("A");
- } else if (bs1==HIGH) {
- checkAnsver("B");
- }
- }
- void checkAnsver(String buttonLabel) {
- String ansver = getAnsver();
- if (ansver.equals(buttonLabel)) {
- disp.print("No!",x,y);
- } else {
- disp.print("Yes!",x,y);
- }
- question = 0;
- }
- String getAnsver() {
- if (question==1) {
- return "A";
- } else if (question==2) {
- return "B";
- } else if (question==3) {
- return "A";
- } else if (question==4) {
- return "B";
- } else if (question==5) {
- return "A";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment