Por enquanto eu fiz esse aplicativo:
Porem o dados não estão sendo mostrados corretamente
Você teria outra solução ou alteração no meu trabalho?
Por enquanto eu fiz esse aplicativo:
Você teria outra solução ou alteração no meu trabalho?
31.- Automatic connection and disconnection cycle of Bluetooth.
p9A01_bluetooth_conec_desco.aia (3.2 KB)
// Juan A. Villalpando
// http://kio4.com/appinventor/9A01_Bluetooth_Conec_Desco.htm
int value_pot0;
void setup() {
Serial.begin(9600);
}
void loop() {
// value_pot0 = analogRead(A0);
value_pot0 = (int) random(0,500);
Serial.println(value_pot0);
delay(100); // It should be slower than the Clock Interval.
}
Clock1.TimerInterval: 5000
Clock2.TimerInterval: 50
BluetoothClient1.DelimiterByte: 10
32.- Two Bluetooths alternately connect and disconnect cyclically.
p9A01_bluetooth_conec_desco_2.aia (3.4 KB)
In these tutorials we saw how to connect two Bluetooth devices at the same time to the same application, for this we use two components, BluetoothClient1 and BluetoothClient2.
https://groups.google.com/g/mitappinventortest/c/tsUYqkXNZ3U/m/__y8bPk3BwAJ
http://kio4.com/appinventor/9X_bluetooth_dos_arduino.htm
We will use a single BluetoothClient1.
The two Bluetooth are sending numbers continuously. Look at the Arduino codes. Just change the range of the random numbers.
Code for Arduino 1. (100...199)
// Juan A. Villalpando
// http://kio4.com/appinventor/9A01_Bluetoot_Conec_Desco.htm
int value_pot0;
void setup() {
Serial.begin(9600);
}
void loop() {
// value_pot0 = analogRead(A0);
value_pot0 = (int) random(100,199);
Serial.println(value_pot0);
delay(100); // It should be slower than the Clock Interval.
}
Code for Arduino 2. (2000...2999)
// Juan A. Villalpando
// http://kio4.com/appinventor/9A01_Bluetoot_Conec_Desco.htm
int value_pot0;
void setup() {
Serial.begin(9600);
}
void loop() {
// value_pot0 = analogRead(A0);
value_pot0 = (int) random(2000,2999);
Serial.println(value_pot0);
delay(100); // It should be slower than the Clock Interval.
}
Clock1.TimerInterval: 5000
Clock2.TimerInterval: 50
BluetoothClient1.DelimiterByte: 10
33.- Two Screens. Screen1 to Connect. Screen2 to view data.
p9A02_bluetooth_dospantallas.aia (5.5 KB)
For the app to work it must be installed.
// Juan A. Villalpando
// http://kio4.com/appinventor/9A02_Bluetooth_Dos_pantallas.htm
#include <SoftwareSerial.h>
SoftwareSerial BT(2,3);
int number = 0;
String numberS = "0";
char caracter = '0';
void setup(){
BT.begin(9600);
Serial.begin(9600);
}
void loop(){
// Send number every 800 ms.
delay(800);
number = number + 1;
if(number == 1000){number = 0;}
Serial.println(number);
numberS = (String) number + '\n';
BT.write(numberS.c_str());
// If receive char 'r' by BT, restart number.
if(BT.available()) {
caracter = BT.read();
Serial.println(caracter);
if(caracter == 'r'){number = 0;}
}
}
ooooooooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooooooooooo
ooooooooooooooooooooooooooooooooo
Similar to this topic: [Extension] Dynamic graph. Shift left graph. Sinusoidal wave. Bluetooth
hello super tutorial YES !!!, a question: Is it possible to transmit a csv file from the arduino / esp8266 to the mobile? if so what are the constraints?
Thanks for reading.
Happy holidays to you
Hello,
I just try to get data (voltage) from Arduino. voltage from the photo resistor.
void loop()
{
int Volt = analogRead(A0);
Serial.print(Volt);
delay(500);
}
I can't see any data in MitappInvertor
Serial.print(Volt);
to
Serial.println(Volt);
if BluetClient.Is Connected...... in a ClockTimer
Clock Timerinterval : 400
BluetoothClient.DelymiterByte: 10
Take a look at the examples in this topic.
It would also help to set global Volt to Bluetooth.ReadText inside that if/then before announcing Volt in a Label.
34.- App sends a number as text via Bluetooth and Arduino converts it to binary. Return.
p9A2_ConvertirBinario.aia (9.5 KB)
a) It converts it to binary with 8 bits.
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
int num = Serial.parseInt(); // Read number received as text
String binary = String(num, BIN); // To binary
while (binary.length() < 8) {
binary = "0" + binary; // Fill 0 left
}
Serial.println(binary); // Print binary number and return.
}
}
oooooooooooooooooooooooooooooooooooooooooooooooooo
b) Binary Positional.
[Start in position 0]
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
int num = Serial.parseInt(); // Read number received as text
String binary = "";
for (int i = 0; i < 48; i++) {
if (i == num) {
binary += "1"; // Agregar "1" en la posición correspondiente al número
} else {
binary += "0"; // Agregar "0" en las demás posiciones
}
}
Serial.println(binary); // Print binary number and return.
}
}
oooooooooooooooooooooooooooooooooooooooooooooooooo
c) It converts it to BCD (Binary-Coded Decimal).
[It is necessary that the input has 4 digits: 1256]
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
String textReceived = Serial.readStringUntil('\n');
if (textReceived.length() == 4) {
for (int i = 0; i < 4; i++) {
int num = textReceived.charAt(i) - '0'; // Get numeric value.
String bcd = String(num, BIN); // To BCD
bcd = ("0000" + bcd).substring(bcd.length()); // BCD with 4 bits
Serial.print(bcd + " "); // Print binary number and return.
}
Serial.println();
}
}
}
35.- Arduino sends two random numbers with decimals, separated by commas.
pA0_Bluetooth_Arduino_envia.aia (10.7 KB)
float temperature = 0.0;
float humidity = 0.0;
String tempera_humidity;
void setup() {
Serial.begin(9600);
}
void loop() {
temperature = random(20, 40) * 5.555;
humidity = random(50, 95) * 3.333;
tempera_humidity = String(temperature, 3) + "," + String(humidity, 3);
Serial.println(tempera_humidity);
delay(1000);
}
36.- Ultrasound SR04 sends distance to App by Bluetooth.
pA0_Bluetooth_Arduino_Ultrasonido.aia (3.0 KB)
Arduino Library Ultrasonic.zip:
http://kio4.com/appinventor/9A0_Resumen_Bluetooth.htm#ultrasonido
#include <Ultrasonic.h>
Ultrasonic ultrasonic(12,13); // (Trig PIN, Echo PIN)
void setup() {
Serial.begin(9600);
}
void loop(){
Serial.println(ultrasonic.Ranging(CM));
delay(500);
}
Hello, I tried this and it's not working, when connecting to HC-05 Bluetooth module it works but on the Check Temperature button when I click it it just freeze. Any help? thanks
I already set the DelimiterByte the value 10, still not working
Not working on me
Well, now it's working, after extensive research and checking the hardware parts I used, the app was not the issue, the problem was the power supply, the wire I use was longer, then I try shorter wire, now it works, the problem was power supply shortage.
Maybe you should save the result in a variable first and then print it to the screen
Привет., сделал приложение по вашему подобию. Только я получаю не 2 переменные с ардуино, а 4 штуки. Но получается, что при первых 8 нажатиях приходит предыдущие значения другой переменной и только на 8 нажатие отображается та переменная какая нужна. как пофиксить?
Here is an updated blocks sample illustrating these ideas ...
BlueTooth_delimiter_sample.aia(3.4 KB)
... Here is an updated blocks sample illustrating these ideas ...
BlueTooth_delimiter_sample.aia(3.4 KB)
...