hi everyone i need help please as soon as possible ..
im trying to send 1bite from my arduino to an android device with the use of bluetooth but im having a problem on how to do so please help .. i badly need it for my thesis.. thankssss
Read Read this before posting a programming question ... - Programming Questions - Arduino Forum and post the code that you are having a problem with.
Your thesisssss issss in danger of not being completed then, sssssince you don't sssssseem to be able to asssssssssk the right quesssssions.
By the way, do you have a problem with your S key? I hope your thesissss isn't filled with extraneous S characters all over the place.
majenko:
Your thesisssss issss in danger of not being completed then, sssssince you don't sssssseem to be able to asssssssssk the right quesssssions.By the way, do you have a problem with your S key? I hope your thesissss isn't filled with extraneous S characters all over the place.
Majenko...you just became THAT guy.
Anways, hakai_24, do you have any prior knowledge to coding before you began this Thesis? In other words, if we were to help you, are we speaking to someone who is going to understand it or are you simply someone who's looking for us to post code on the wall so that you can just upload?
here what i use to control the arduino using the android app i made.
#include <Servo.h>
Servo myservo;
int mspeed(1700);
byte serialA;
void setup(){
Serial.begin(9600);
}
void loop(){
if (serialA==1){
myservo.attach(13);
mspeed = 1700;
myservo.writeMicroseconds(mspeed);
}
else {
serialA==0;
myservo.detach();
}
}
void serialEvent(){
serialA= Serial.read();
Serial.println(serialA);
}
Hakai_24, there are multiple things wrong with this code. Have you tried debugging the code? You're going to want to make sure the code does what it is you want it to before you even implement bluetooth data transfer.
If you can get your code to work with the serial monitor, then you can get it to work (most of the time) with an Android device.
Write a code that does exactly what you want and try to control it from the serial monitor.
the codes that im using works .. the android app i made sends 1 byte to the arduino via bluetooth and to make sure that it is working I used the serial monitor .. but i am having a hard time on sending 1byte from the arduino to the android app . i tries using serial.write(); but it doesnt work the android didnt receive the 1 byte because the value of my label suppost to change when it receives one byte.. thanks
So... the Arduino software works, but the android software doesn't. Are you sure the byte is being received by the Arduino in the first place?
I want to know what this line is supposed to be doing:
int mspeed(1700);
It's not a syntax I'm familiar with, but C++ seems to like it, but is it actually doing what you think it's doing? Not that that'd affect the serial side of things...
I'd add some kind of Arduino-side feedback - maybe an LED to say the byte has been received from Android correctly. Unless of course your servo is providing that feedback? Is the servo actually working when you communicate through Android?
Android to arduino works, but arduino to android does not.
Do you get anything at all from the arduino, even garbage?
What app are you using ? What you could try, is use a program called Putty, if your arduino is sending anything out, putty should be able to show it.
I think I am lost in all of this. You have a Bluetooth shield on your Arduino that is communicating with your Android device? (Android can see and connect to the Arduino BT device) Or are you communicating through a serial port between the two? The BT shield should have libraries available to make the programming easier. Or it's possible that the BT shield directly connects to the Tx/Rx lines and has its own built in code that figures out what it's supposed to do thus making any secondary party code unnecessary. My guess is the later. If so, and you can receive and display data being sent from Android but cannot receive data from Arduino, there's a good chance the code on the Android side is to blame. Also, you cannot simply write into your serial monitor and hope that gets sent. You need to specify. You have serial.println which is going to send a end return along w/ it. Which is the garbage HazardsMind was referring to. Do you receive garbage? That program Putty is a good one to use to debug.