Guest User

arduinolcd

a guest
Mar 12th, 2023
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include "SPI.h"
  2. #include "NRFLite.h"
  3. #include <LiquidCrystal.h>
  4.  
  5. const int rs = 5, en = 6, d4 = 4, d5 = 3, d6 = 2, d7 = 7;
  6. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  7. const static uint8_t RADIO_ID = 0; // Our radio's id. The transmitter will send to this id.
  8. const static uint8_t PIN_RADIO_CE = 9;
  9. const static uint8_t PIN_RADIO_CSN = 10;
  10.  
  11. NRFLite _radio;
  12. char _hello[30];
  13. int newsize;
  14. char n[30];
  15. char m[30];
  16.  
  17. void setup() {
  18. lcd.begin(8, 2);
  19. Serial.begin(115200);
  20.  
  21. if (!_radio.init(RADIO_ID, PIN_RADIO_CE, PIN_RADIO_CSN)) {
  22. Serial.println("Cannot communicate with radio");
  23. while (1)
  24. ; // Wait here forever.
  25. }
  26. }
  27.  
  28. void loop() {
  29. while (_radio.hasData()) {
  30. _radio.readData(&_hello);
  31. Serial.println(_hello);
  32. int newsize = strlen(_hello) - 1;
  33. Serial.println(newsize);
  34.  
  35. if (newsize <= 30) {
  36. Serial.println(" 0th row and 0th column");
  37.  
  38. for (int k = 0; k <= 7; k++) {
  39. lcd.setCursor(0, 0);
  40. n[k] = _hello[k];
  41. delay(200);
  42. lcd.print(n);
  43. //Serial.print(n);
  44. }
  45. if (newsize > 8) {
  46. Serial.println(" 0th row and 1st column \n");
  47. for (int t = 8; t <= 15; t++) {
  48. lcd.setCursor(0, 1);
  49. n[t] = _hello[t];
  50. delay(200);
  51. lcd.print(n);
  52. //Serial.print(n);
  53. }
  54. }
  55. }
  56. }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment