Advertisement
juberth

Untitled

Sep 26th, 2013
5,901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2.  
  3. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  4.  
  5. String text = "";
  6.  
  7. void setup() {
  8.   lcd.begin(16, 2);  
  9.  
  10.   Serial.begin(9600);  
  11. }
  12.  
  13. void loop() {  
  14.   if(Serial.available() > 0){
  15.      
  16.      lcd. clear();
  17.      
  18.      delay(500);
  19.      leerCadena();
  20.   }
  21. }
  22.  
  23. //Metodo para leer cada byte de la cadena enviada de
  24. //Processing
  25. void leerCadena(){
  26.  if(Serial.available() > 0){
  27.    
  28.     char dato = Serial.read();
  29.    
  30.     text += dato;
  31.    
  32.    
  33.     leerCadena();
  34.  }  
  35.  
  36.  lcd.print(text);
  37.  
  38.  
  39.  if(text.length() > 15){
  40.    
  41.  
  42.    lcd.setCursor(0,2);
  43.    
  44.    text = text.substring(16,text.length());
  45.    
  46.    lcd.print(text);
  47.  }
  48.  
  49.  text = "";
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement