Arduino schéma - arduino.sk

Displej nokia 5110

Programovanie arduina
Príspevky: 2
Registrovaný: Uto 10. Sep 2013 22:51:29

Displej nokia 5110

Poslaťod aughostino » Ned 25. Feb 2018 12:25:29

Ahojte,

ucim sa pracovat s arduino nano a narazil som na problem s displejom nokia 5110. Mam napisany jednoduchy program, ktory by mal vypisat datum a cas na displeji v koordinatoch x=0 y=5. Prikaz
LcdWriteData(DateTime());
mi nefunguje. Ako deklarovat datum a cas aby kompilator nemal problem ho previest do formatu dd/mm/yyyy hh:mm:ss.

kniznicu mam od Adafruit https://github.com/adafruit/Adafruit-PC ... CD-library

Program vyzera nasledovne
Kód: Vybrať všetko
#include "font.h";
#include "display5110.h"
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
void LcdWriteString(char *characters) {
  while(*characters) LcdWriteCharacter(*characters++);
  }
void LcdWriteCharacter(char character) {
  for(int i=0; i<5; i++) LcdWriteData(ASCII[character - 0x20][i]);
  LcdWriteData(0x00);
  }

void LcdWriteData(byte dat) {
  digitalWrite(DC, HIGH); //DC pin is low for commands   
  digitalWrite(CE, LOW);
  shiftOut(DIN, CLK, MSBFIRST, dat); //transmit serial data
  digitalWrite(CE, HIGH);
  }
void LcdXY(int x, int y) {
  LcdWriteCmd(0x80 | x);  // Column.
  LcdWriteCmd(0x40 | y);  // Row.
  }
void LcdWriteCmd(byte cmd) {
  digitalWrite(DC, LOW); //DC pin is low for commands
  digitalWrite(CE, LOW);
  shiftOut(DIN, CLK, MSBFIRST, cmd); //transmit serial data
  digitalWrite(CE, HIGH);
  }
void setup() {
  Serial.begin(9600);
    Wire.begin();
    RTC.begin();
  // Check to see if the RTC is keeping time.  If it is, load the time from your computer.
  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // This will reflect the time that your sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }

  pinMode(RST, OUTPUT);
  pinMode(CE, OUTPUT);
  pinMode(DC, OUTPUT);
  pinMode(DIN, OUTPUT);
  pinMode(CLK, OUTPUT);
  digitalWrite(RST, LOW);
  digitalWrite(RST, HIGH);
  LcdWriteCmd(0x21);  // LCD extended commands   
  LcdWriteCmd(0xB0);  // set LCD Vop (contrast) 
  LcdWriteCmd(0x04);  // set temp coefficent   
  LcdWriteCmd(0x14);  // LCD bias mode 1:40   
  LcdWriteCmd(0x20);  // LCD basic commands   
  LcdWriteCmd(0x0C);  // LCD normal video   
   
  for(int i=0; i<504; i++) LcdWriteData(0x00); // clear LCD
   


  }
void loop() {
DateTime now = RTC.now();
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print('/');
    Serial.print(now.year(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();   

  LcdXY(0,5);
  LcdWriteData(DateTime());
  delay(1000);
  }


dalsi problem, nedari sa mi vypisat na displeji znak ° (degree). prikaz LcdWriteCharacter(char(223)); vypise hieroglif :D

Obrázok užívateľa
Príspevky: 311
Registrovaný: Pon 19. Nov 2012 12:01:08
Bydlisko: HC/BA

Re: Displej nokia 5110

Poslaťod tomXX » Uto 10. Apr 2018 22:16:14

Napíš sem chybovú hlášku kompilera, uvidíme.
blog.sitepoint.sk - zaujímavé riešenia okolo Arduina

Späť na Software