Hello everyone, I am a beginner in the Mit App Inventor environment, so please help. I would like to create an application that when we press the button to unlock, it displays an additional window where we will have to enter the password we set before, if we enter the wrong one, it will say that the wrong password, and if the right one, the application sends the value "1" to the bluetooth module and works normally. After pressing the second button, it receives the location from the GPS module via bluetooth and shows it on the map. I have created the map, the blocks to change to Screen2 also, but I have no idea how to create the blocks in Screen2 with this password and location receive.
#include <LiquidCrystal_I2C.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <PWMServo.h>
PWMServo myservo;
LiquidCrystal_I2C lcd(0x27, 16, 2); // Inicjalizacja obiektu wyświetlacza LCD
SoftwareSerial bluetooth(2, 3); // RX, TX
TinyGPSPlus gps; // Inicjalizacja obiektu TinyGPSPlus
// Zmienne przechowujące dane o prędkości
float speedKMH = 0;
int currentPos = 0; // początkowa pozycja serwomechanizmu
void setup()
{
Serial.begin(9600); // Inicjalizacja połączenia szeregowego
bluetooth.begin(9600); // inicjalizacja modułu Bluetooth
myservo.attach(9); // podłączenie serwomechanizmu do pinu 9
myservo.write(currentPos); // ustawienie początkowej pozycji serwomechanizmu
// Inicjalizacja wyświetlacza LCD
lcd.begin();
lcd.backlight();
// Wyświetlenie napisu "Predkosciomierz" na wyświetlaczu LCD
lcd.setCursor(0, 0);
lcd.print("Predkosciomierz");
}
void loop()
{
while (Serial.available() > 0) {
if (gps.encode(Serial.read())) {
// Pobranie danych o lokalizacji
double latitude = gps.location.lat();
double longitude = gps.location.lng();
bluetooth.print(latitude, 6);
bluetooth.print(",");
bluetooth.println(longitude, 6);
Serial.print(latitude, 6);
Serial.print(",");
Serial.println(longitude, 6);
// Obliczenie prędkości w km/h
float speedMS = gps.speed.mps();
speedKMH = speedMS * 3.6;
}
}
if (bluetooth.available()) { // jeśli dane są dostępne z modułu Bluetooth
char incomingByte = bluetooth.read(); // odczytaj dane
if (incomingByte == '1') { // jeśli otrzymano wartość 1
if (currentPos != 90) { // jeśli serwomechanizm nie jest w pozycji 90 stopni
myservo.write(90);
currentPos = 90; // aktualizuj pozycję serwomechanizmu
}
}
if (incomingByte == '0') { // jeśli otrzymano wartość 0
if (currentPos != 0) { // jeśli serwomechanizm nie jest już w pozycji 0 stopni
myservo.write(0);
currentPos = 0; // aktualizuj pozycję serwomechanizmu
}
}
}
// Wyświetlenie prędkości na wyświetlaczu LCD
lcd.setCursor(0, 1);
lcd.print("Speed:");
lcd.print(speedKMH, 1);
lcd.print(" km/h ");
}