Advertisement
mikroavr

nextion_text

Jun 7th, 2022
1,508
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. unsigned long cur_time, old_time;
  3. int count = 0;
  4.  
  5. void setup() {
  6.   // put your setup code here, to run once:
  7.   Serial.begin(115200);
  8.   Serial1.begin(9600, SERIAL_8N1, 18, 19);
  9. }
  10.  
  11. void loop() {
  12.   cur_time = millis();
  13.   if (cur_time - old_time >= 1000) {
  14.     count++;
  15.     Serial.println(count                                                         );
  16.     tampil_text("t0", "Counter");
  17.     tampil_text("t1", String(count));
  18.     old_time = cur_time;
  19.   }
  20.  
  21. }
  22.  
  23. void tampil_text(String _add_txt, String _txt_display) {
  24.   String buf_txt = _add_txt + ".txt="  + "\"" + _txt_display + "\"";
  25.   Serial1.print(buf_txt);
  26.   Serial1.write(0xff);
  27.   Serial1.write(0xff);
  28.   Serial1.write(0xff);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement