Advertisement
nwb99

doom

Feb 23rd, 2023 (edited)
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.16 KB | None | 0 0
  1. #include <Arduino.h>
  2. #include <LiquidCrystal.h>
  3. #include "DOOM.h"
  4.  
  5. #define LCD_RS    9
  6. #define LCD_EN    8
  7. #define LCD_D0   14 // A0
  8. #define LCD_D1   15 // A1
  9. #define LCD_D2    2
  10. #define LCD_D3    3
  11. #define LCD_D4    4
  12. #define LCD_D5    5
  13. #define LCD_D6    6
  14. #define LCD_D7    7
  15.  
  16. #define LCD_W    16
  17. #define LCD_H     2
  18.  
  19. #define EMPTY    "                "
  20. #define STARTMSG "Hello, world!"
  21.  
  22. LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D0, LCD_D1, LCD_D2, LCD_D3, LCD_D4,
  23.                   LCD_D5, LCD_D6, LCD_D7);
  24.  
  25. void drawDOOM_1();
  26. void drawDOOM_2();
  27.  
  28. void setup() {
  29.   lcd.begin(LCD_W, LCD_H);
  30.   lcd.clear();
  31.   lcd.setCursor(0, 0);
  32.   lcd.print(STARTMSG);
  33.   delay(1500);
  34.   lcd.clear();
  35. }
  36.  
  37. void loop() {
  38.   drawDOOM_1();
  39.   delay(27);
  40.   drawDOOM_2();
  41.   delay(27);
  42. }
  43.  
  44. void drawDOOM_1() {
  45.   lcd.setCursor(4, 1);
  46.   lcd.print("        ");
  47.   lcd.createChar(0, bottom[0]);
  48.   lcd.createChar(1, bottom[1]);
  49.   lcd.createChar(2, bottom[2]);
  50.   lcd.createChar(3, bottom[3]);
  51.   lcd.createChar(4, bottom[4]);
  52.   lcd.createChar(5, bottom[5]);
  53.   lcd.createChar(6, bottom[6]);
  54.   lcd.createChar(7, bottom[7]);
  55.  
  56.   lcd.setCursor(4, 1);
  57.   lcd.write(byte(0));
  58.   lcd.setCursor(5, 1);
  59.   lcd.write(byte(1));
  60.   lcd.setCursor(6, 1);
  61.   lcd.write(byte(2));
  62.   lcd.setCursor(7, 1);
  63.   lcd.write(byte(3));
  64.   lcd.setCursor(8, 1);
  65.   lcd.write(byte(4));
  66.   lcd.setCursor(9, 1);
  67.   lcd.write(byte(5));
  68.   lcd.setCursor(10, 1);
  69.   lcd.write(byte(6));
  70.   lcd.setCursor(11, 1);
  71.   lcd.write(byte(7));
  72. }
  73.  
  74. void drawDOOM_2() {
  75.   lcd.setCursor(4, 0);
  76.   lcd.print("        ");
  77.   lcd.createChar(0, top[0]);
  78.   lcd.createChar(1, top[1]);
  79.   lcd.createChar(2, top[2]);
  80.   lcd.createChar(3, top[3]);
  81.   lcd.createChar(4, top[4]);
  82.   lcd.createChar(5, top[5]);
  83.   lcd.createChar(6, top[6]);
  84.   lcd.createChar(7, top[7]);
  85.  
  86.   lcd.setCursor(4, 0);
  87.   lcd.write(byte(0));
  88.   lcd.setCursor(5, 0);
  89.   lcd.write(byte(1));
  90.   lcd.setCursor(6, 0);
  91.   lcd.write(byte(2));
  92.   lcd.setCursor(7, 0);
  93.   lcd.write(byte(3));
  94.   lcd.setCursor(8, 0);
  95.   lcd.write(byte(4));
  96.   lcd.setCursor(9, 0);
  97.   lcd.write(byte(5));
  98.   lcd.setCursor(10, 0);
  99.   lcd.write(byte(6));
  100.   lcd.setCursor(11, 0);
  101.   lcd.write(byte(7));
  102. }
  103.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement