12.- Keypad in App sends number to Arduino & HM-10, show in LCD-I2C.
p110i_UNO_hm10_LCD.aia (192.5 KB)
This example is based on this topic.
A keypad sends a number of less than 5 digits by BLE HM-10 to Arduino UNO and is displayed on an LCD-I2C
// http://kio4.com/arduino/161_HM10_BLE.htm
#include <Wire.h>
// Pantalla LCD
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
// LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
#include <SoftwareSerial.h>
// El TXD del módulo al pin 2 (RX) del Arduino.
// El RXD del módulo al pin 3 (TX) del Arduino.
SoftwareSerial HM10(2, 3);
// byte caracter = "";
char caracter = "";
String mensaje = "";
void setup(){
Serial.begin(9600);
HM10.begin(9600);
lcd.begin(16,2);// Columnas y filas de LCD.
}
void loop(){
if(HM10.available()) {
caracter = HM10.read();
// Serial.println(caracter);
mensaje = mensaje + caracter;
if(caracter == NULL ) {
Serial.println(mensaje);
mensaje = mensaje.substring(0, mensaje.length() - 1); // Delete last char
lcd.clear();
lcd.setCursor(0,0);
lcd.print(mensaje);
mensaje = "";
delay(100);
}
}
}

