Advertisement
mzh_pb

Untitled

May 22nd, 2024
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include "SPI.h"
  2. #include "Adafruit_GFX.h"
  3. #include "Adafruit_ILI9341.h"
  4.  
  5. const int TFT_CS = 10;
  6. const int TFT_DC = 9;
  7.  
  8. Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
  9.  
  10. const int TILE_W = 15;
  11. const int BOARD_W = 10 * TILE_W, BOARD_H = 20 * TILE_W;
  12.  
  13. bool board[10][20];
  14.  
  15. void setup() {
  16.   // put your setup code here, to run once:
  17.   Serial.begin(9600);
  18.   tft.begin();
  19.   for (int i = 0; i < 8; i++) {
  20.     pinMode(i, INPUT_PULLUP);
  21.   }
  22.   tft.fillScreen(ILI9341_BLACK);
  23.   tft.drawRect(5, 5, BOARD_W + 2, BOARD_H + 2, ILI9341_WHITE);
  24.   board[2][5] = 1;
  25. }
  26.  
  27. void loop() {
  28.   // put your main code here, to run repeatedly:
  29.   tft.setTextColor(ILI9341_WHITE);
  30.   tft.setCursor(0, 0);
  31.   // Serial.println(digitalRead(5));
  32.   delay(100);
  33.  
  34.   for (int i = 0; i < 10; i++) {
  35.     for (int j = 0; j < 20; j++) {
  36.       if (board[i][j]) {
  37.         tft.fillRect(6 + i * TILE_W, 6 + j * TILE_W, TILE_W, TILE_W, ILI9341_BLUE);
  38.       }
  39.     }
  40.   }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement