Dateien nach "/" hochladen

This commit is contained in:
2026-02-23 11:10:24 +01:00
parent 2bb60138a9
commit 70d54afe48

View File

@@ -3,6 +3,37 @@
#include <LiquidCrystal_I2C.h> #include <LiquidCrystal_I2C.h>
#include <Wire.h> #include <Wire.h>
// Bonus code
class pixeldraw {
private:
LiquidCrystal_I2C* lcd;
void constructbuf(int x, int y, byte* buf) {
buf[y] = B10000 >> x;
return buf;
}
public:
pixeldraw(LiquidCrystal_I2C* _lcd) {
lcd = _lcd;
}
void setpix(int _x, int _y) {
// calculate cell x and y
int cellx = _x/5;
int celly = _y/8;
int x = _x%5; // calculate modulo
int y = _y%8; // calculate modulo
byte buf[8] = { // load from cellbuf
0,0,0,0,0,0,0,0
};
constructbuf(x,y,buf);
lcd->createChar(cellx+(celly*16), buf);
lcd->clear();
lcd->setCursor(cellx, celly);
lcd->write(byte(cellx+(celly*16)));
}
};
int led = 7; // pin Nummern für jwl. Komponente int led = 7; // pin Nummern für jwl. Komponente
int bt = 8; int bt = 8;
long highscore = 999999; // speichert highscore in einer Variable long highscore = 999999; // speichert highscore in einer Variable
@@ -19,6 +50,13 @@ void setup() {
lcd.init(); // LCD initialisieren lcd.init(); // LCD initialisieren
lcd.clear(); lcd.clear();
lcd.backlight(); // backlight an machen lcd.backlight(); // backlight an machen
pixeldraw drawer(&lcd);
for (int y=0;y<(8*8);y++) {
for (int x=0;x<(16*5);x++) {
drawer.setpix(x, y);
delay(1);
}
}
} }
void loop() { void loop() {