MMP Cvičenie 3: Rozdiel medzi revíziami
Zo stránky SensorWiki
Bez shrnutí editace |
|||
Riadok 66: | Riadok 66: | ||
Arduino | |||
=== Arduino === | |||
* [http://www.arduino.cc/en/Tutorial/LCDLibrary LCD Library] | * [http://www.arduino.cc/en/Tutorial/LCDLibrary LCD Library] | ||
<source lang="c"> | |||
/* | |||
LiquidCrystal Library - Hello World | |||
Demonstrates the use a 16x2 LCD display. | |||
The circuit: | |||
* LCD RS pin to digital pin 12 | |||
* LCD R/W pin to digital pin 12 | |||
* LCD Enable pin to digital pin 11 | |||
* LCD D4 pin to digital pin 4 | |||
* LCD D5 pin to digital pin 5 | |||
* LCD D6 pin to digital pin 6 | |||
* LCD D7 pin to digital pin 7 | |||
*/ | |||
#include <LiquidCrystal.h> // include the library | |||
// initialize the library with the numbers of the interface pins | |||
// LiquidCrystal(RS, RW, EN, D4, D5, D6, D7) | |||
LiquidCrystal lcd( 3, 2, 1, 4, 5, 6, 7); | |||
void setup() { | |||
// set up the LCD's number of columns and rows: | |||
lcd.begin(16, 2); | |||
// Print a message to the LCD. | |||
lcd.print("Ahoj!"); | |||
} | |||
void loop() { | |||
// set the cursor to column 0, line 1 | |||
// (note: line 1 is the second row, since counting begins with 0): | |||
lcd.setCursor(0, 1); | |||
// print the number of seconds since reset: | |||
lcd.print(millis()/1000); | |||
} | |||
</source> | |||
Misc: | Misc: | ||
* [http://www.geocities.com/dinceraydin/djlcdsim/djlcdsim.html LCD Display Simulator] | * [http://www.geocities.com/dinceraydin/djlcdsim/djlcdsim.html LCD Display Simulator] | ||
* [http://www.geocities.com/dinceraydin/lcd/charcalc.htm Custom Character Calculator] | * [http://www.geocities.com/dinceraydin/lcd/charcalc.htm Custom Character Calculator] |
Verzia z 12:21, 4. október 2010
Programovateľný LCD displej
- Toto je skompilovaná ukážka možností práce s displejom.
Ďalej máte k dispozícii knižnicu (lcd.c, lcd.h) s fungujúcou inicializáciou displeja a príkazmi na ovládanie. Pripravené sú funkcie:
void lcdInit4(void); // inicializácia displeja 4-bitovo
void lcdControlWrite(unsigned char c_data); // zapíše príkaz do displeja
void lcdDataWrite(unsigned char w_data) ; // zapíše znak na LCD na aktuálnu pozíciu
Úlohy
Najprv sa snažte pochopiť, ako je vytvorený vzorový program, ako sa konfiguruje pripojenie LCD k portom, skontrolujte konfiguráciu. Potom s pomocou manuálu k displeju zobrazte na displeji nejaký text a zrealizujte nasledovné funkcie:
- . posun kurzora doprava / dolava
- . posun obsahu displeja doprava / dolava
- . napíšte funkciu funkcia void lcdGotoXY(riadok, stlpec)
- . clear displeja (a obnovenie povodneho obsahu displeja)
- . zadefinujte si vlastné znaky a zobrazte ich spolu s iným textom. Povinne aspoň jeden znak s diakritikou a znak stupeň, zobrazte teplotu.
Zdrojáky
#include "lcd.h"
int main(void)
{
unsigned char znak;
lcdInit4();
lcdControlWrite(1<<LCD_CLR);
for(znak='A';znak<'E';znak++)
lcdDataWrite(znak);
lcdControlWrite(0x40+0x80);
for(znak='F';znak<'Q';znak++)
lcdDataWrite(znak);
while (1);
return 0;
}
Literatúra
- Katalógové listy
- Radič Hitachi HD44780
- Displej 2x16 DEM 16216 SYH-LY
- Displej 2x16 DEM 20231 SYH-PY
- Nuts & Volts: Demystifying Character Based LCDs
- Hitachi 44780 Driver
- 2x16 Parallel LCD datasheet
- Stamp Works - pp. 73 and more [1]
Arduino
/*
LiquidCrystal Library - Hello World
Demonstrates the use a 16x2 LCD display.
The circuit:
* LCD RS pin to digital pin 12
* LCD R/W pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 4
* LCD D5 pin to digital pin 5
* LCD D6 pin to digital pin 6
* LCD D7 pin to digital pin 7
*/
#include <LiquidCrystal.h> // include the library
// initialize the library with the numbers of the interface pins
// LiquidCrystal(RS, RW, EN, D4, D5, D6, D7)
LiquidCrystal lcd( 3, 2, 1, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Ahoj!");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
}
Misc: