Connect MIT APP inventor to Arduino via bluetooth

Good evening,

I want to connect the MIT APP inventor to Arduino. I am using HC-06 bluetooth module. There are four connection on the bluetooth module VCC, GND, RX and TX.
I tried the MIT code added below but it did not connect
Can you assist please.

Typically, you fill the Picker Elements BEFORE Picking, not AFTER Picking.

Thank you for the reply.
I used a voltage divider for the RX pin of the bluetooth HC-06 and I am using pins 0 and 1 on Arduino for TX and RX communication

I downloaded the below code in Arduino

/* Arduino and HC-05 Bluetooth Module Tutorial
 * 
 * by Dejan Nedelkovski, www.HowToMechatronics.com
 * 
 */
 
#define ledPin 13
int state = 0;

void setup() {
 pinMode(ledPin, OUTPUT);
 digitalWrite(ledPin, LOW);
 Serial.begin(38400); // Default communication rate of the Bluetooth module
}

void loop() {
 if(Serial.available() > 0){ // Checks whether data is comming from the serial port
 state = Serial.read(); // Reads the data from the serial port
 }

 if (state == '0') {
 digitalWrite(ledPin, LOW); // Turn LED OFF
 Serial.println("LED: OFF"); // Send back, to the phone, the String "LED: ON"
 state = 0;
 }
 else if (state == '1') {
 digitalWrite(ledPin, HIGH);
 Serial.println("LED: ON");;
 state = 0;
 } 
}

Can you assist me in writing a simple application to control the internal LED of Arduino
Thanks in advance

I tried this code following the tutorial in the link below. The bluetooth is connected but the internal LED of arduino is not controlled by the application. I only used the companion I did not download the code.
I added images of the circuits and the built code. Also, the serial mointor in Arduino does not receive any information from the application. Can you assist please

https://howtomechatronics.com/tutorials/arduino/how-to-build-custom-android-app-for-your-arduino-project-using-mit-app-inventor/




I'm not one of this board's hardware experts ( @uskiara , @ChrisWard , ...) so I can't comment on your wiring.

I do notice in your blocks that you are trying to read from Bluetooth without first verifying that there is data available, and you are not doing it in a Clock Timer.

This board has a Tutorials section with a thread loaded with samples.

Also see

1 Like

Dear @asma_Al_Maqdi,
please refer to the following post:

I've posted therein a couple of working codes: one for AI2 and the other for Arduino, and a wiring schematic.
Please take care that if you use pins 0,1 of the Arduino board, they are typically allocated to the serial monitor, therefore, if you use them also for the BT connection you could fall into a data collision. Moreover only a few brands of HC0x have the baudrate factory set @38400. Mostly they are set @9600. Please be aware of that as well. What I usually suggest is to verify first the Arduino cabling ad baudrate settings. To this purpose you can split your project in two phases: at the beginning you could use a ready made app (i.e. Serial Bluetooth Terminal, free on Google playstore) so to eliminate any doubt at Arduino side, then, when you are sure that the Arduino is correctly set and coded, then, you can go on with your app and apply the hints already suggested by @ABG .
Best wishes.

(..and take a look or use my sample code as a starter)

EDIT I had a zoomed look to your wiring: the green wire from the Arduino board (Tx) shall enter the voltage divider not directly to the HC06 and most important: Arduino Tx must be crossed to the shield's Rx (and visa versa).
The power supply to the HC06 can be sourced from the 5vdc pin of the UNO board as well. Only the HC06 Rx pin shall be protected (and therefore the need to put the voltage divider).

1 Like

Hello asma

ABG and Uskiara combined have probably solved your issues, I just wanted to compliment your excellent post that gives the necessary information for Power Users to find those needles in a haystack. We so often get "urgent" posts without any useful information at all!

1 Like