Mini Documents Bluetooth Reader

Mini Documents Bluetooth Reader

Send mini documents to a 16x2 LCD display.

  • 6 views
  • 0 comments
  • 2 respects

Components and supplies

Apps and online services

About this project

With this project, you'll be able to send a mini document of up to 64 characters, and read them on a 16x2 LCD. With a push button, you can see the other lines that don't fit on the screen.

Code

the good codeArduino
#include <SoftwareSerial.h> //Librería que permite establecer comunicación serie en otros pin
#include <LiquidCrystal.h>




// made by Gibran Hernandez
//supergxp@gmail.com








//Aquí conectamos los pins RXD,TDX del módulo Bluetooth.
SoftwareSerial modulo(10,11); //10 RX, 11 TX.
LiquidCrystal lcd (5, 3, 7, 9, 8, 12);
 
int green=4;
String hola = "";
int botonaso=2;
int boton = HIGH;
int red=6;
char cadena[255]; //Creamos un array de caracteres de 256 cposiciones
int i=0; //Tamaño actual del array
int columna =0;
int renglon = 0;
int length = 0;
int estado = 0;
int adios = 0;
int guante = 0;
byte resets[8]={
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000 
};

String prueba = "";
void setup()
{
  modulo.begin(9600);
  Serial.begin(9600);
  pinMode(green,OUTPUT);
  pinMode(boton,INPUT);
  pinMode(red,OUTPUT);
  lcd.begin(16, 2);
  lcd.createChar(4, resets);
  
}
 
void loop(){
  boton = digitalRead(botonaso);



  //Cuando haya datos disponibles
  if(modulo.available())
  {
 
     
    Serial.print("estado =");
    Serial.println(estado);
       
      /* Codigo debug */
     /* if(estado == 0)
      {
        digitalWrite(green,HIGH);
        Serial.println("ENCENDIDO");
        
        estado = 1;
        
      } else {
        digitalWrite(green,LOW);
        Serial.println("apagado");
         estado = 0;
      }*/
     /* Fin Codigo debug */
     
    char dato=modulo.read(); //Guarda los datos carácter a carácter en la variable "dato"
    Serial.println(dato);

    cadena[i++]=toUpperCase(dato); //Vamos colocando cada carácter recibido en el array "cadena"

 
    /* Codigo debug */
    Serial.println("Se ha pulsado una tecla");
   
    Serial.println(cadena);

    prueba = cadena;
    
    if(prueba.length() <= 15){
      Serial.println("chica");
        borra();
        lcd.home();
             lcd.print(prueba);
             
    } 

   else if (prueba.length() > 15 && prueba.length() < 32){
        borra();
      Serial.println("mediana");
      lcd.setCursor(0,0);
      lcd.print(prueba.substring(0,16));
     
      lcd.setCursor(0,1 );
      lcd.print(prueba.substring(16,32));
    }




else if (prueba.length() > 31 && prueba.length() < 48){
    borra();
    hola= "";
Serial.println("grande");

      lcd.setCursor(0,0);
      lcd.print(prueba.substring(0,16));
      
      lcd.setCursor(0,1 );
      lcd.print(prueba.substring(16,32));

      Serial.println(prueba.length());
     
     hola = hola + "grande";
}

else if (prueba.length() > 47 && prueba.length() < 64){
    borra();
    hola= "";
Serial.println("muy grande");

      lcd.setCursor(0,0);
      lcd.print(prueba.substring(0,16));
      
      lcd.setCursor(0,1 );
      lcd.print(prueba.substring(16,32));

      Serial.println(prueba.length());
    
     hola = hola + "muy grande";
}



/*
  if(izeof(cadena) < 15){
    borradisplay();
    lcd.home();
    lcd.print(cadena);
  }
   /* if (sizeof(cadena) > 15){
      lcd.setCursor(0,0);
      lcd.print(substring(0,15, cadena));
      
      lcd.setCursor(0,1 );
      lcd.print(substring(16,sizeof(cadena)-1, cadena));
    }
    else{
      lcd.print(cadena);
    }  

         
    if(strstr (cadena,"GREEN ON") != 0)
      {
        digitalWrite(green,HIGH);
        Serial.println("prende");    
      }
      else{
        digitalWrite(green,LOW);
        Serial.println("apaga");

      }
*/
/*
       if(strstr (cadena,"BLUE ON") != 0)
      {
        digitalWrite(yellow,HIGH);
        Serial.println("prende");

        clean();
    
      }
      else{
        digitalWrite(yellow,LOW);
        Serial.println("apaga");

      }

      if(strstr (cadena,"CLEAN") != 0)
      {
        borradisplay();
        Serial.println("clean");
         
        clean();
    
      }


    clean();
*/
  
  


/* if((prueba.length() != prueba.length() <= 15) || (prueba.length() != (prueba.length() > 15 && prueba.length() < 30)) && hola ==0){

clean();

    
  }*/}

 else if(boton == LOW && hola == "grande"){
        Serial.println("boton presionado");
        lcd.setCursor(0,0);
      lcd.print(prueba.substring(16,32));
      
      lcd.setCursor(0,1 );
      lcd.print(prueba.substring(32,48));
        hola = "";
      }

 else if(boton == LOW && hola == "muy grande"){
        Serial.println("boton presionado");
        lcd.setCursor(0,0);
      lcd.print(prueba.substring(32,48));
      
      lcd.setCursor(0,1 );
      lcd.print(prueba.substring(48,64));
        hola = "";
      }


 else if(boton == LOW && hola == "gigante"){
        Serial.println("boton presionado");
        lcd.setCursor(0,0);
      lcd.print(prueba.substring(32,48));
      
      lcd.setCursor(0,1 );
      lcd.print(prueba.substring(48,64));
        hola = "gigante 1";
      }

 else if(boton == LOW && hola == "gigante 1"){
        Serial.println("boton presionado");
        lcd.setCursor(0,0);
      lcd.print(prueba.substring(64,80));
      
      lcd.setCursor(0,1 );
      lcd.print(prueba.substring(80,96));
        hola = "";
      }








      
















    
  else if (hola == "") {
 clean();
}
  else if (prueba.length() >= 81) {
 clean();
}


  //  Serial.print("hola = ");
  //Serial.println(hola);
  }
 
//Limpia el array
void clean()
{
  for (int cl=0; cl<=i; cl++)
  {
    cadena[cl]=0;
    prueba[cl]=0;
    adios=0;
    hola="";
  }
  i=0;
}
void borra()
{
  for(columna = 0; columna <= 16; columna++){
    lcd.setCursor(columna, 0);
    lcd.write(4);

    lcd.setCursor(columna, 1);
    lcd.write(4);

  }//for
   Serial.print("hola = ");
  Serial.println(hola);
}

void clean2()
{
  for (int cl=0; cl<=i; cl++)
  {
   
    prueba[cl]=0;
    adios=0;
  }
  i=0;
}

Schematics

the good sketch
Minidocumento ht33n23viy

Comments

Similar projects you might like

View Serial Monitor Over Bluetooth

by millerman4487

  • 5,735 views
  • 9 comments
  • 32 respects

Bluetooth Controlled Car

Project tutorial by JANAK13

  • 12,660 views
  • 19 comments
  • 43 respects

Bluetooth Controlled Servo

Project tutorial by

  • 10,984 views
  • 17 comments
  • 37 respects

Bluetooth control led with lcd led status display real time.

Project tutorial by Youssef Sabaa

  • 23,537 views
  • 4 comments
  • 44 respects

Attiny85/84 with Bluetooth

by Robin Kanattu Thomas

  • 14,505 views
  • 0 comments
  • 56 respects
Add projectSign up / Login