// #include <Button.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define SCREEN_ADDRESS 0x3d
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#include <Arduino.h>
// Структура для хранения информации о вопросах
struct Question {
char questionText[100]; // Текст вопроса
byte answerOptions[4][100]; // Массив массивов для хранения вариантов ответов
byte correctAnswer; // Номер правильного ответа (от 0 до 3)
};
// Структура для хранения информации о вопросах
Question questions[] = {
{"What is the significance of RS flip-flop in a digital circuit?", {"Signal amplification", "Storing one bit of information", "Analog to digital conversion", "High frequency signal generation"}, 1},
{"What is the name of an element that can change the logical level at its output?", {"Inverter", "Resistor", "Capacitor", "Transistor"}, 0},
{"What type of element is used to delay time in the monostable mode of the 555 timer?", {"Resistor", "Inverter", "Capacitor", "Transistor"}, 2},
{"Which transistor is most commonly used in 2N2222 bipolar transistor circuits?", {"MOSFET", "JFET", "IGBT", "BJT"}, 3},
{"What principle underlies the operation of a circuit that includes an RS trigger and an inverter?", {"Signal amplification", "Memory", "Management", "Management"}, 1},
{"What happens to the DISCH input when a logic '1' appears at the inverter input?", {"Charging", "Discharged", "Nothing happens", "Inverted"}, 1},
{"What is the main function of the “inverter” in this circuit?", {"Signal multiplication", "Signal inversion", "Signal amplification", "Signal filtering"}, 1},
{"What voltage should be at the THRESHOLD input in relation to the supply voltage?", {"Less", "More", "Equal", "Doesn't matter"}, 1},
{"What can a monostable mode circuit be used for?", {"Signal generation", "Time measurement", "Signal conversion", "Signal amplification"}, 1},
{"Which parameters greatly affect the time delay in a monostable mode 555 timer circuit?", {"Capacitance and inductance", "Resistance and power", "Temperature and voltage", "Pulse frequency and duration"}, 2},
// Добавьте дополнительные вопросы здесь...
};
// Количество вопросов
byte numQuestions = sizeof(questions) / sizeof(questions[0]);
// Текущий вопрос
byte currentQuestion = 0;
int buttonPins[] = {34, 35, 32, 33};
int checkButton() {
// пины кнопок
const int numButtons = sizeof(buttonPins) / sizeof(buttonPins[0]);
for (int i = 0; i < numButtons; i++) {
// Проверяем, нажата ли кнопка
if (!digitalRead(buttonPins[i])) {
// Возвращаем номер нажатой кнопки
return i;
}
}
// Если ни одна кнопка не нажата, возвращаем -1
return -1;
}
void setup() {
// Инициализация выводов для кнопок и дисплея
for (int i = 0; i < 4; i++) {
pinMode(buttonPins[i], INPUT_PULLUP);
}
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
display.display();
delay(2000); // Pause for 2 seconds
// Clear the buffer
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(10, 10);
display.println("xxx");
display.display();
}
void loop() {
// Отображение текущего вопроса
// display.setCursor(10, 10);
// display.print("Вопрос ");
// display.print(currentQuestion + 1);
// display.print(": ");
// display.println(questions[currentQuestion].questionText);
// int cnt = 0;
// // Отображение вариантов ответов
// for (int i=0;i<4;i++){
// display.setCursor(1,1);
// display.print(questions[currentQuestion].questionText);
// display.setCursor(2,1);
// display.print(questions.answerOptions);
// delay(5000);
// if(cnt == checkButton()){cnt++; continue;}
// else{continue;}
// }
// if(cnt<5) {
// display.setCursor(1,1);
// display.print("Лучше чем ничего");
// }
// if(cnt>6) {
// display.setCursor(1,1);
// display.print("Хорошо");
// }
// if(cnt>8) {
// display.setCursor(1,1);
// display.print("Отлично");
// }
}