W tym projekcie wykorzystałem wyświetlacz T162BNL2 oparty na kontrolerze zgodnym z Hitachi HD44780. Schemat połączeń wyświetlacza z Arduino tutaj. Dodatkowo zasiliłem podświetlenie wyświetlacza - piny 15(led+) i 16(led-) z 3.3V z Arduino.
Kod programu:
Rezultat:
Aktualizacja
Rozbudowałem poprzedni program o możliwość wyświetlania tekstów zadanych z konsoli szeregowej.
Rezultat:
Kod programu:
#include <LiquidCrystal.h>
// LiquidCrystal(rs, rw, enable, d4, d5, d6, d7)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2); // 16 znaków 2 wiersze
lcd.print(" pozdrawiam ");
lcd.setCursor(5, 1); // ustawienie kursora 6 kolumna i 2 wiersz
lcd.print("sebsob");
}
void loop() {
delay(100);
}
Rezultat:
Aktualizacja
Rozbudowałem poprzedni program o możliwość wyświetlania tekstów zadanych z konsoli szeregowej.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int incomingByte = 0;
int column = 0;
int row = 0;
int firstByte = 0;
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print(" napisz cos ");
lcd.setCursor(0, 1);
lcd.print(" z konsoli ");
lcd.setCursor(0,0);
}
void loop() {
if (Serial.available() > 0) {
if (firstByte == 0) {
lcd.clear();
firstByte = 1;
}
incomingByte = Serial.read();
lcd.print(incomingByte,BYTE);
if ((row == 0) and (column == 15)) {
column = 0;
row = 1;
lcd.setCursor(0,1);
}
if ((row == 1) and (column == 15)) {
column = 0;
row = 0;
lcd.setCursor(0,0);
}
column = column + 1;
}
}
Rezultat:
Komentarze
Prześlij komentarz