Hey, I'm doing a project for school that basically consists on a HC-05 as well as a SR-HC04 connected to an Arduino UNO Rev4. The SR-HC04 (proximity sensor) prints the distance in the serial monitor I can connect the HC-05 with MIT App Inventor. The thing is that I don't seem to find the way for printing the serial monitor in the MIT App that I made.
Any help with this would be greatly appreciated! Will provide any other information and details that may be needed.
For now, I'll show what i have:
Arduino's code:
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3);
#define Pecho 6
#define Ptrig 7
float duracion, distancia;
void setup() {
Serial.begin(9600);
BTSerial.begin(9600);
pinMode(Pecho, INPUT);
pinMode(Ptrig, OUTPUT);
pinMode(13, 1);
}
void loop() {
if (BTSerial.available()) {
Serial.write(BTSerial.read());
}
if (Serial.available()) {
BTSerial.write(Serial.read());
}
digitalWrite(Ptrig, LOW);
delayMicroseconds(2);
digitalWrite(Ptrig, HIGH);
delayMicroseconds(10);
digitalWrite(Ptrig, LOW);
duracion = pulseIn(Pecho, HIGH);
distancia = (duracion/2) / 29;
if (distancia >= 500 || distancia <= 0){
Serial.println("---");
}
else {
Serial.print(distancia);
Serial.println("cm");
digitalWrite(13, 0);
digitalWrite(4, 1);
}
delay(800);
}
MIT App Inventor:
Designer part:
Blocks part: