Hi everyone,
I am working on a project using the MIT App inventor and trying to pair it with HC-05 Bluetooth module. However, I am facing an issue when trying to connect the MIT App to the HC-05 Bluetooth module on a Samsung Galaxy20+ and higher models. The app is not able to establish a Bluetooth connection with the HC-05.
Has anyone experienced similar issues with MIT App Inventor on these Samsung devices? Are there any specific compatibility settings or configurations I need to check or adjust for the Bluetooth to work?
Any advice or solution would be greatly appreciated!
Hi everyone,
I'm having trouble getting a HC-05 Bluetooth to pair with MIT APP inventor. The app is not identifying the Bluetooth device, and I cant seem to figure out why. I keep getting error 515 and 507 even though I give permission for the app and apk file. I am using Galaxy 23 phone to download the app. Here the Arduino code and MIT blocks I've used so far. can anyone help me understand what might be going wrong or suggest a solution to get the HC-05 pair correctly? Any assistance would be greatly appreciated!
Blocks:
Arduino code
//Includes the Arduino Stepper Library
#include <Stepper.h>
#include <SoftwareSerial.h>
// Defines the number of steps per rotation
const int stepsPerRevolution = 2038;
char receivedChar;
SoftwareSerial BTSerial(19,18);
// Creates an instance of stepper class
// Pins entered in sequence IN1-IN3-IN2-IN4 for proper step sequence
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);
void setup() {
// put your setup code here, to run once:
BTSerial.begin(9600);
Serial.begin(9600);
Serial.println("The bluetooth gates are open.\n Connect to HC-05 from any other bluetooth device with 1234 as pairing key!.");
myStepper.setSpeed(15);
}
// set stepper speed to 15 rpm
void loop() {
// put your main code here, to run repeatedly:
if(BTSerial.available()>0){
char command=BTSerial.read();
if(command=='1'){
myStepper.step(256);//move the motor at 45 degree angle
//pause for 5min
delay(50000);
//Stepper.step(0);//stop the motor
} else if(command == '0') {
// Stop the stepper motor (by not calling stepper.step())
// or you could rotate it to home position if needed.
// Rotate CCW quickly at 10 RPM
myStepper.setSpeed(10);
myStepper.step(-stepsPerRevolution);
delay(10000);
// Stepper.step(0);//this will stop the motor
}
}
}
Dear @jorge_Meza,
sadly, honestly, your code is far from having the possibility to work.
For example here below: the blue circle indicates that instead of using two separate "if blocks" you should use only the if..then..else construct.
The two red circles indicate that you use the wrong block "Blink_standby.Text" with a color: most prbably you would use the Blink_standby.TextColor instead,
Obviously this doesn't solve the lack of communication, but it is anyway an error.
Before attempting to put all together, i.e. communication and stepper motor driving, I strongly suggest you to make the communication working before and, only after, to integrate the Arduino code with the stepper motor part (which Arduino board are you using ? What are the pins 18 and 19, where you attach the HC05 ? Please bw aware that the SoftwareSerial needs digital pins, better with PWM capabilities.
My hint is therefore, before trying to do a fully integrated software, that you have a look to @Juan_Antonio's web site (www.kio4.com) where you can find many "ready-made" examples of BT use between Arduino and AI2 apps. In that site you'll surely find a working code from which you can start and elaborate your own.
Best regards.