Teplomer

Zo stránky Robotický krúžok
Verzia z 19:12, 18. december 2017, ktorú vytvoril Tiger (diskusia | príspevky)
(rozdiel) ← Staršia verzia | Aktuálna úprava (rozdiel) | Novšia verzia → (rozdiel)
Skočit na navigaci Skočit na vyhledávání


Program:

  1. include<dht.h>


  1. define dht_apin A0


dht DHT;


  1. include<dht.h>


  1. define dht_apin A0


/* hociaky komentar

  aj na viac riadkov */

// jednoriadkovy komentar

// include the library code


  1. include <Wire.h>


  1. include <LiquidCrystal_I2C.h>


  1. include <string.h>


/**********************************************************/


// initialize the library with the numbers of the interface pins


LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display


const int inPin = 0;


void setup()

{

 lcd.init();  //initialize the lcd


 lcd.backlight();  //open the backlight


} /*********************************************************/


void loop()


{

 DHT.read11(dht_apin);


 char slovo[] = " stupnov Celzia ";


 char str[16];


   int value = analogRead(inPin);


 float millivolts = DHT.temperature;


 float celsius = millivolts / 1;


 delay(600);


   sprintf(str, " *** %02d.%03d ***", (int)celsius, (int)((celsius - (int)celsius)));


   lcd.clear();


   lcd.setCursor(15,0);


   for (int positionCounter1 = 0; positionCounter1 < strlen(str); positionCounter1++)
   {
     //lcd.scrollDisplayLeft();  //Scrolls the contents of the display one space to the left.


     lcd.setCursor(positionCounter1 ,0);


     lcd.print(str[positionCounter1]);  // Print a message to the LCD.


     delay(100);  //wait for 250 microseconds
   }  
   for (int positionCounter1 = 0; positionCounter1 < strlen(slovo); positionCounter1++)
   {
     //lcd.scrollDisplayLeft();  //Scrolls the contents of the display one space to the left.


     lcd.setCursor(positionCounter1,1);


     lcd.print(slovo[positionCounter1]);  // Print a message to the LCD.


     delay(100);  //wait for 250 microseconds


   }  

}


/************************************************************/