Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned int pomiar = 0.0;
- float napiecie = 0.00;
- unsigned int procent;
- #include <LiquidCrystal.h>
- LiquidCrystal lcd(2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13);
- void przygotujlcd(){
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Napiecie xxxxV");
- lcd.setCursor(0, 2);
- lcd.print("Naswietlenie xx%");
- procent = 0;
- napiecie = 0.00;
- }
- void setup() {
- pinMode(5, OUTPUT);
- lcd.begin(16, 2);
- przygotujlcd();
- }
- void wykonajpomiar(){
- pomiar = analogRead(A0);
- napiecie = pomiar * (5.00 / 1024.00);
- if(napiecie == 0.0){
- lcd.clear();
- lcd.setCursor(5, 0);
- lcd.print("Awaria");
- lcd.setCursor(4, 2);
- lcd.print("czujnika");
- while(napiecie < 1.00){napiecie = analogRead(A0);delay(10);}
- przygotujlcd();
- }
- else{
- procent = napiecie / 4.96 * 100;
- }
- return 0;
- }
- void wyswietlwynik(){
- lcd.setCursor(9, 0);
- lcd.print(napiecie);
- lcd.setCursor(13, 2);
- lcd.print(procent);
- return 0;
- }
- void loop() {
- wykonajpomiar();
- wyswietlwynik();
- delay(200);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement