Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. //zad2
  2. // include the library code:
  3. #include <LiquidCrystal.h>
  4.  
  5. // initialize the library by associating any needed LCD interface pin
  6. // with the arduino pin number it is connected to
  7. const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7            ;
  8. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  9.  
  10. void setup() {
  11.   lcd.begin(16, 2);
  12. }
  13.  
  14. void loop() {
  15.   lcd.setCursor(0,0);  
  16.   lcd.print(digitalRead(A0));
  17.   lcd.setCursor(0, 1);
  18.   float voltage = analogRead(A0)*(5.0 / 1023.0);
  19.   lcd.print(voltage);
  20.   lcd.print(" V");
  21.   delay(500);
  22.   lcd.clear();
  23. }
  24.  
  25. //zad3
  26. #include <LiquidCrystal.h>
  27. const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7            ;
  28. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  29.  
  30. int incomingByte = 0;
  31.  
  32. void setup() {
  33.   Serial.begin(9600);
  34. }
  35.  
  36. void loop() {
  37.   while(Serial.available()>0){
  38.       incomingByte = Serial.read();
  39.       lcd.print((char)incomingByte);
  40.       Serial.print(incomingByte);
  41.       Serial.print(' ');
  42.       delay(1000);
  43.     }
  44.     lcd.clear();
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement