Advertisement
talofer99

lcd_printOut

Dec 30th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2.  
  3. // initialize the library by associating any needed LCD interface pin
  4. // with the arduino pin number it is connected to
  5. const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
  6. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  7.  
  8. //const int buttonPin2 = 2; // the number of the pushbutton pin
  9. //const int buttonPin3 = 3; // the number of the pushbutton pin
  10. //const int buttonPin4 = 4; // the number of the pushbutton pin
  11. const int buttonPin8 = 8; // the number of the pushbutton pin
  12. int buttonState = 0; // variable for reading the pushbutton status
  13.  
  14. // Возвращаем отправленное значение
  15.  
  16. void setup() {
  17. // set up the LCD's number of columns and rows:
  18. lcd.begin(16, 2);
  19. pinMode(buttonPin8, INPUT);
  20. // initialize the serial communications:
  21. Serial.begin(9600);
  22. }
  23.  
  24. void loop() {
  25. // read the state of the pushbutton value:
  26. buttonState = digitalRead(buttonPin8);
  27. if (buttonState == HIGH) {
  28. //send command to smif
  29. Serial.println("Send 5");
  30. }
  31. // when characters arrive over the serial port...
  32. if (Serial.available()) {
  33. // wait a bit for the entire message to arrive
  34. delay(100);
  35. // clear the screen
  36. lcd.clear();
  37. // read all the available characters
  38. while (Serial.available() > 0) {
  39. // display each character to the LCD
  40. char readData = Serial.read();
  41. if (readData != 10 && readData != 13) {
  42. lcd.write(readData);
  43. }
  44. }
  45. }
  46.  
  47. delay(200);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement