Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SD.h>
- #include <SPI.h>
- #include <Wire.h>
- #include <Keypad.h>
- const byte rows = 4;
- const byte cols = 4;
- char keys[rows][cols] = {
- {'1','2','3','A'},
- {'4','5','6','B'},
- {'7','8','9','C'},
- {'*','0','#','D'}
- };
- byte rowPins[rows] = {11,10,9,8};
- byte colPins[cols] = {7,6,5,4};
- Keypad key = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);
- #include <Adafruit_GFX.h> // Core graphics library
- //#include <Adafruit_TFTLCD.h> // Hardware-specific library
- //Adafruit_TFTLCD tft(A3, A2, A1, A0, A4);
- #include <MCUFRIEND_kbv.h>
- MCUFRIEND_kbv tft; // hard-wired for UNO shields anyway.
- #include <TouchScreen.h>
- #if defined(__SAM3X8E__)
- #undef __FlashStringHelper::F(string_literal)
- #define F(string_literal) string_literal
- #endif
- // most mcufriend shields use these pins and Portrait mode:
- uint8_t YP = A1; // must be an analog pin, use "An" notation!
- uint8_t XM = A2; // must be an analog pin, use "An" notation!
- uint8_t YM = 7; // can be a digital pin
- uint8_t XP = 6; // can be a digital pin
- uint8_t SwapXY = 0;
- // Assign human-readable names to some common 16-bit color values:
- #define BLACK 0x0000
- #define BLUE 0x001F
- #define RED 0xF800
- #define GREEN 0x07E0
- #define CYAN 0x07FF
- #define MAGENTA 0xF81F
- #define YELLOW 0xFFE0
- #define WHITE 0xFFFF
- void show_tft(void)
- {
- tft.begin(9600);
- tft.setCursor(9, 7);
- tft.setTextSize(4);
- tft.setTextColor(CYAN, BLACK);
- tft.print('Moje ime je Gospodin Limeni. Uskoro pocinjemo kviz.');
- }
- char keypressed = ' ';
- File myFile;
- int TacniOdgovori = 0;
- int NeTacniOdgovori = 0;
- void setup() {
- }
- void loop() {
- for (int x = 1; x<16; x++) {
- if (x == 1){
- File myFile = SD.open("1. Pitanje.txt");
- if (myFile) {
- tft.print("1. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod C');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod C');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod C');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (x == 2){
- File myFile = SD.open("2. Pitanje.txt");
- if (myFile) {
- tft.print("2. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod B');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod B');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod B');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (x == 3){
- File myFile = SD.open("3. Pitanje.txt");
- if (myFile) {
- tft.print("3. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (x == 4){
- File myFile = SD.open("4. Pitanje.txt");
- if (myFile) {
- tft.print("4. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod B');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod B');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod B');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (x == 5){
- File myFile = SD.open("5. Pitanje.txt");
- if (myFile) {
- tft.print("5. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (x == 6){
- File myFile = SD.open("6. Pitanje.txt");
- if (myFile) {
- tft.print("6. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan dogovor je pod A');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- tft.println('Tacan odgovor je pod A');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- tft.println('Tacan odgovor je pod A');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (x == 7){
- File myFile = SD.open("7. Pitanje.txt");
- if (myFile) {
- tft.print("7. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod C');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod C');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod C');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (x == 8){
- File myFile = SD.open("8. Pitanje.txt");
- if (myFile) {
- tft.print("8. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (x == 9){
- File myFile = SD.open("9. Pitanje.txt");
- if (myFile) {
- tft.print("9. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (x == 10){
- File myFile = SD.open("10. Pitanje.txt");
- if (myFile) {
- tft.print("10. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod C');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod C');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod C');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (x == 11){
- File myFile = SD.open("11. Pitanje.txt");
- if (myFile) {
- tft.print("11. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod B');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod B');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod B');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (x == 12){
- File myFile = SD.open("12. Pitanje.txt");
- if (myFile) {
- tft.print("12. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod D');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (x == 13){
- File myFile = SD.open("13. Pitanje.txt");
- if (myFile) {
- tft.print("13. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan dogovor je pod A');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- tft.println('Tacan odgovor je pod A');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- tft.println('Tacan odgovor je pod A');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (x == 14){
- File myFile = SD.open("14. Pitanje.txt");
- if (myFile) {
- tft.print("14. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan dogovor je pod A');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- tft.println('Tacan odgovor je pod A');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- tft.println('Tacan odgovor je pod A');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (x == 15){
- File myFile = SD.open("15. Pitanje.txt");
- if (myFile) {
- tft.print("15. Pitanje.txt");
- while (myFile.available()) {
- tft.print(myFile.read());
- char keypressed = key.getKey();
- }
- }
- }
- if (keypressed = 'A') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod B');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'B') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor je tacan');
- TacniOdgovori = TacniOdgovori + 1;
- }
- if (keypressed = 'C') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod B');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- if (keypressed = 'D') {
- myFile.close();
- tft.reset();
- tft.println('Vas odgovor nije tacan');
- tft.println('Tacan odgovor je pod B');
- NeTacniOdgovori = NeTacniOdgovori + 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement