Animation - ein einzelner Pixel wandert
Auf unserem LCD soll sich ein einzelner Pixel bewegen.
#include <LiquidCrystal.h> LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7); int t = 150; byte ball0[] = { 0b00100, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000}; byte ball1[] = { 0b00000, 0b00100, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000}; byte ball2[] = { 0b00000, 0b00000, 0b00100, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000}; byte ball3[] = { 0b00000, 0b00000, 0b00000, 0b00100, 0b00000, 0b00000, 0b00000, 0b00000}; byte ball4[] = { 0b00000, 0b00000, 0b00000, 0b00000, 0b00100, 0b00000, 0b00000, 0b00000}; byte ball5[] = { 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00100, 0b00000, 0b00000}; byte ball6[] = { 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00100, 0b00000}; byte ball7[] = { 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00100}; void setup() { lcd.begin(16, 2); lcd.clear(); lcd.createChar( 0, ball0); lcd.createChar( 1, ball1); lcd.createChar( 2, ball2); lcd.createChar( 3, ball3); lcd.createChar( 4, ball4); lcd.createChar( 5, ball5); lcd.createChar( 6, ball6); lcd.createChar( 7, ball7); } void loop() { runter(7, 0); runter(7, 1); hoch(7, 1); hoch(7, 0); } void runter(int spalte, int zeile) { for (int i = 0; i < 8; i++) { lcd.setCursor(spalte, zeile); lcd.write((uint8_t)i); delay(t); } lcd.setCursor(spalte, zeile); lcd.print(" "); } void hoch(int spalte, int zeile) { for (int i = 7; i >= 0; i--) { lcd.setCursor(spalte, zeile); lcd.write((uint8_t)i); delay(t); } lcd.setCursor(spalte, zeile); lcd.print(" "); }
#in clude <LiquidCrystal.h> LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7); int t = 110; byte ball0[] = { 0b10000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000}; byte ball1[] = { 0b01000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000}; byte ball2[] = { 0b00100, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000}; byte ball3[] = { 0b00010, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000}; byte ball4[] = { 0b00001, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000}; void setup() { lcd.begin(16, 2); lcd.clear(); lcd.createChar( 0, ball0); lcd.createChar( 1, ball1); lcd.createChar( 2, ball2); lcd.createChar( 3, ball3); lcd.createChar( 4, ball4); } void loop() { for (int i = 0; i < 16; i++) rechts(i, 0); for (int i = 15; i >=0; i--) links(i, 1); } void rechts(int spalte, int zeile) { for (int i = 0; i < 5; i++) { lcd.setCursor(spalte, zeile); lcd.write((uint8_t)i); delay(t); } lcd.setCursor(spalte, zeile); lcd.print(" "); } void links(int spalte, int zeile) { for (int i = 4; i >= 0; i--) { lcd.setCursor(spalte, zeile); lcd.write((uint8_t)i); delay(t); } lcd.setCursor(spalte, zeile); lcd.print(" "); }
|