Jump to content
ELFORUM - Forumul electronistilor
Sign in to follow this  
Guest

LCD BIG FONT

Recommended Posts

Guest
Am acest cod 
/*  Display_Counter.ino - Example for displaying large numbers on LCD displays using the HD44780 driver.  Displays the number of seconds since last boot on the display.     The circuit:  * LCD RS pin to digital pin 12  * LCD Enable pin to digital pin 11  * LCD D4 pin to digital pin 5  * LCD D5 pin to digital pin 4  * LCD D6 pin to digital pin 3  * LCD D7 pin to digital pin 2  * LCD R/W pin to ground  * LCD V0 pin to digital pin 9  * LCD backlight Anode pin to digital pin 10  Copyright (C) 2014 Sean Auffinger  This program is free software: you can redistribute it and/or modify  it under the terms of the GNU General Public License as published by  the Free Software Foundation, either version 3 of the License, or  (at your option) any later version.  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License for more details.  You should have received a copy of the GNU General Public License  along with this program.  If not, see <http://www.gnu.org/licenses/>.*/// https://github.com/seanauff/BigNumbers#include <LiquidCrystal.h>#include <BigNumbers.h>const int lcdD7Pin = 2; // LCD D7 pinconst int lcdD6Pin = 3; // LCD D6 pinconst int lcdD5Pin = 4; // LCD D5 pinconst int lcdD4Pin = 5; // LCD D4 pinconst int lcdEPin = 11; // LCD E Pinconst int lcdRSPin = 12; // LCD RS pinLiquidCrystal lcd(lcdRSPin, lcdEPin, lcdD4Pin, lcdD5Pin, lcdD6Pin, lcdD7Pin); // construct LCD objectBigNumbers bigNum(&lcd); // construct BigNumbers object, passing to it the name of our LCD objectvoid setup(){  /*  The following 2 lines change the PWM frequency of digital pins 9 and 10.  On Arduino Uno, these pins are controlled by Timer1.  On Arduino MEGA2560, these pins are controlled by Timer2.  Use the line that you need and comment out the other.  See <http://playground.arduino.cc/Main/TimerPWMCheatsheet> for more details.  */  TCCR1B = TCCR1B & 0b11111000 | 0x01; // use for Arduino Uno  // TCCR2B = TCCR1B & 0b11111000 | 0x01; // use for Arduino Mega2560  pinMode(9,OUTPUT);  pinMode(10,OUTPUT);  analogWrite(9,50); // set LCD contrast with PWM - change this value if hard to read display  analogWrite(10,127); // set LCD backlight with PWM  lcd.begin(16,2); // setup LCD rows and columns  bigNum.begin(); // set up BigNumbers  lcd.clear(); // clear display}void loop(){  int currentTime = millis() / 1000; // assigns the current time since boot in tenths of a second to currentTime  byte lastDigit = currentTime % 10;  currentTime = currentTime /= 10;  bigNum.displayLargeInt(currentTime, 0, 4, false);  // print out the decimal point and the digit after it  lcd.setCursor(12, 1);  lcd.print(".");  lcd.print(lastDigit);}

si l-am modificat sa-mi afiseze temperatura folosind NTC

#include <math.h>double ThermistorC(int RawADC) { double Temp; Temp = log(10000.0*((1024.0/RawADC-1)));  Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp ); Temp = Temp - 273.15;           return Temp;}#include <LiquidCrystal.h>#include <BigNumbers.h>const int lcdD7Pin = 2; // LCD D7 pinconst int lcdD6Pin = 3; // LCD D6 pinconst int lcdD5Pin = 4; // LCD D5 pinconst int lcdD4Pin = 5; // LCD D4 pinconst int lcdEPin = 11; // LCD E Pinconst int lcdRSPin = 12; // LCD RS pinLiquidCrystal lcd(lcdRSPin, lcdEPin, lcdD4Pin, lcdD5Pin, lcdD6Pin, lcdD7Pin); // construct LCD objectBigNumbers bigNum(&lcd); // construct BigNumbers object, passing to it the name of our LCD objectvoid setup(){  /*  The following 2 lines change the PWM frequency of digital pins 9 and 10.  On Arduino Uno, these pins are controlled by Timer1.  On Arduino MEGA2560, these pins are controlled by Timer2.  Use the line that you need and comment out the other.  See <http://playground.arduino.cc/Main/TimerPWMCheatsheet> for more details.  */  //TCCR1B = TCCR1B & 0b11111000 | 0x01; // use for Arduino Uno   TCCR2B = TCCR1B & 0b11111000 | 0x01; // use for Arduino Mega2560  pinMode(9,OUTPUT);  pinMode(10,OUTPUT);  analogWrite(9,50); // set LCD contrast with PWM - change this value if hard to read display  analogWrite(10,127); // set LCD backlight with PWM  lcd.begin(20, 4); // setup LCD rows and columns  bigNum.begin(); // set up BigNumbers  lcd.clear(); // clear display}void loop(){  int valC;                  double tempC;                valC=analogRead(1);        tempC=ThermistorC(valC);  bigNum.displayLargeInt(tempC, 0, 4, false);  delay(250);}

Problema mea este cum pot sa afisez si o zecimala asa cum se obtine zecimala la numarator (primul cod):

  ...  byte lastDigit = currentTime % 10;  currentTime = currentTime /= 10;  bigNum.displayLargeInt(currentTime, 0, 4, false);  // print out the decimal point and the digit after it  lcd.setCursor(12, 1);  lcd.print(".");  lcd.print(lastDigit);
Edited by Guest

Share this post


Link to post
Share on other sites

Adica vrei sa afisezi si o zecimala de-a lui tempC?Nu stiu cat de eficienta e, dar prima idee care-mi vine e sa folosesti o variabila int ca sa "separi"partea intreaga a lui tempC. Dupa, o scazi din tempC si-ti raman zecimalele. Inmultesti zecimalele cu 10 si salvezi rezultatul intr-un char. Asta va fi prima zecimala:

double tempC;uint16_t tempC_intPart;uint8_t tempC_zecimale;tempC=ThermistorC(valC);tempC_intPart = tempC;tempC_zecimale = (tempC - tempC_intPart)*10;lcd.setCursor(12, 1);lcd.print(".");lcd.print(tempC_zecimale);

Share this post


Link to post
Share on other sites
Guest

Multumesc d-lui Liviu M pentru ajutorul acordat si voi posta si eu codul cu mici modificari:

#include <math.h>double ThermistorC(int RawADC) { double Temp; Temp = log(10000.0*((1024.0/RawADC-1)));  Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp ); Temp = Temp - 273.15;           return Temp;}      double tempC;      uint16_t tempC_intPart;      uint8_t tempC_zecimale;float maxi = 0,mini = 100;                                       // Max/Min temperature variables with initial values. LM35 in simple setup only measures Temp above 0.int i;#include <LiquidCrystal.h>#include <BigNumbers.h>const int lcdD7Pin = 2; // LCD D7 pinconst int lcdD6Pin = 3; // LCD D6 pinconst int lcdD5Pin = 4; // LCD D5 pinconst int lcdD4Pin = 5; // LCD D4 pinconst int lcdEPin = 11; // LCD E Pinconst int lcdRSPin = 12; // LCD RS pinLiquidCrystal lcd(lcdRSPin, lcdEPin, lcdD4Pin, lcdD5Pin, lcdD6Pin, lcdD7Pin); // construct LCD objectBigNumbers bigNum(&lcd); // construct BigNumbers object, passing to it the name of our LCD objectunsigned long previousMillis = 0;        // will store last time LED was updated // constants won't change :const long interval = 1200;           // interval at which to blink (milliseconds)String txt_row0, txt_row1, txt_row2, txtsc;;void setup(){   txt_row0 = "Max = ";  txt_row1 = "Min = ";  txt_row2 = "Termometru > NTC 10K";  txtsc=" Big Font Number    ";    lcd.begin(20, 4); // setup LCD rows and columns  bigNum.begin(); // set up BigNumbers  lcd.clear(); // clear display}void loop(){    unsigned long currentMillis = millis();      if (currentMillis - previousMillis >= interval) {        previousMillis = currentMillis;     int valC;                  double tempC;                valC=analogRead(1);        tempC=ThermistorC(valC);  bigNum.displayLargeInt(tempC, 0, 2, false);        tempC_intPart = tempC;      tempC_zecimale = (tempC - tempC_intPart)*10;      lcd.setCursor(6, 0);      lcd.print((char)223);      lcd.print("C");      lcd.setCursor(6, 1);      lcd.print(".");      lcd.print(tempC_zecimale);            lcd.setCursor(9, 0);  lcd.print(txt_row0);  lcd.setCursor(9, 1);  lcd.print(txt_row1);  lcd.setCursor(0, 2);  lcd.print(txt_row2);            if(tempC > maxi) {maxi = tempC;}   // set max temperature     if(tempC < mini) {mini = tempC;}   // set min temperature          lcd.setCursor(15, 0);     lcd.print(maxi, 1);     lcd.setCursor(15, 1);     lcd.print(mini, 1);              }            lcd.setCursor(0, 3);           txtsc=ScrollTxt(txtsc);           lcd.print(txtsc);           delay(200);     }         String ScrollTxt(String txt){ return txt.substring(1,txt.length()) + txt.substring(0, 1); }

de aici puteti downloda libraria BigNumbers.h

 

https://github.com/seanauff/BigNumbers

 

si aici un film:

 

https://www.youtube.com/watch?v=uMtjS_iWTcw

 

Daca aveti si alte pareri nu ezitati.

Edited by Guest

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines