Advertisement
impossibru666

Untitled

Oct 23rd, 2016
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.03 KB | None | 0 0
  1. unsigned int pomiar = 0.0;
  2. float napiecie = 0.00;
  3. unsigned int procent;
  4.  
  5. #include <LiquidCrystal.h>
  6.  
  7. LiquidCrystal lcd(2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13);
  8. void przygotujlcd(){
  9.   lcd.clear();
  10.   lcd.setCursor(0, 0);
  11.   lcd.print("Napiecie xxxxV");
  12.   lcd.setCursor(0, 2);
  13.   lcd.print("Naswietlenie xx%");
  14.   procent = 0;
  15.   napiecie = 0.00;
  16. }
  17.  
  18. void setup() {
  19.   pinMode(5, OUTPUT);
  20.   lcd.begin(16, 2);
  21.   przygotujlcd();
  22.   }
  23. void wykonajpomiar(){
  24.   pomiar = analogRead(A0);
  25.   napiecie = pomiar * (5.00 / 1024.00);
  26.   if(napiecie == 0.0){
  27.     lcd.clear();
  28.     lcd.setCursor(5, 0);
  29.     lcd.print("Awaria");
  30.     lcd.setCursor(4, 2);
  31.     lcd.print("czujnika");
  32.     while(napiecie < 1.00){napiecie = analogRead(A0);delay(10);}    
  33.     przygotujlcd();
  34.     }
  35.   else{
  36.     procent = napiecie / 4.96 * 100;
  37.   }
  38.   return 0;
  39.   }
  40. void wyswietlwynik(){
  41.   lcd.setCursor(9, 0);
  42.   lcd.print(napiecie);
  43.   lcd.setCursor(13, 2);
  44.   lcd.print(procent);
  45.   return 0;
  46. }
  47. void loop() {
  48.  
  49.   wykonajpomiar();
  50.   wyswietlwynik();
  51.   delay(200);
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement