Honours Project

Hi guys, first post. Im doing my 4th year honours project at university. I am using a Arduino Fio with accelerometer that needs to detect head movement. However when i try to upload my code i get the message that the serial port that the Bluetooth unit is using is being used by another program when it isn't :~ Has anyone had a similar problem or point me in the right direction.

Thanks

Post your code and make sure the BT module is NOT connected to the Tx/Rx pins when you upload your sketch. Also you cannot communicate to the BT module with the serial monitor, use Putty.

const int xPin = 0; const int yPin = 1;

void setup() { Serial.begin(9600); }

void loop() { int xValue; int yValue;

xValue = analogRead(xPin); yValue = analogRead(yPin);

Serial.print("X value = "); Serial.print(xValue);

Serial.print("Y value = "); Serial.print(yValue); delay(100); }

That's my code that im trying. I got it from the arduino cookbook and it says that it is for an accelerometer. I am a beginner at this coding stuff and I have probably missed loads.

Thanks for the reply

Are these

const int xPin = 0; const int yPin = 1;

on the digital side or analog side. There is a difference. If they are analog, then rename them to A0 and A1 and try that.

Also you should include Serial.println() after Serial.print(yValue);

Thanks i will try that.
The book had serial.printin() and when i tried it, it came up with an error in the code.

Thanks for your help, much appreciated.

Just tried that there. Its still shows the same problem that COM4 is being used by another program and that i need to quit the other program and try again. In my Bluetooth settings my Bluetooth module 'RoboBlue' is using COM4 with its direction as incoming.

Should that code communicate with the Bluetooth module and react to the accelerometers movement?

You can't communicate to the BT module with the serial monitor. You need to use Putty.

Hi mate thanks for your help so far. I have downloaded putty and im having problems. In my bluetooth settings the RoboBlue is showing up as COM3 outgoing when it is paired up. When i try and open putty with COM3 it says that it cannot open the serial port. :~

What about COM4?

If you can see the serial port but not open it, that might be because some other application has already got the port open.

COM 4 comes up with the message that it is used by another program within arduino and Putty and when choosing serial port in arduino it will not allow me to choose COM3. I have attached a screenshot of my bluetooth settings showing COM3/4.
Thanks

Ok try this, close out both putty and the arduino software also turn off the BT module, and turn it back on and reopen Putty. Then try to connect it.

I don't understand why that config window is showing two unidirectional COM ports rather than a single bidirectional COM port - is that normal?

I suggest you look in Device Manager and see which COM ports appear when you bring up the Bluetooth device. Do you see the two COM ports appear?

I don't understand why that config window is showing two unidirectional COM ports rather than a single bidirectional COM port - is that normal?

Yea its normal, but you would only use the outgoing COM, never the incoming. But for his issue, it sounds like something else is talking on that port.

Check your device manager.

So i did what you said and turned BT on then opened Putty and it communicated fine with COM3 then when i opened up arduino it finally let me select COM3 in the serial port bit. But it still says that COM3 is being used by another program and that i should quit it and try again :~

Thanks again

Update. I am now communicating with the accelerometer through putty it is throwing out tones of numbers when i put my code into Putty. Not sure what the numbers mean. Sorry for my incompetence and lack of knowledge.

Post your code as of now, I you made any changes.

Its the same code as before except i have changed A0 and A1 to A4 and A5 as they are the pins in use. Now i think i just need to output a graph to show the directionality of the accelerometer. I dont know much about putty but can i use that to run a graph outputting the accelerometer?

Thanks again

You can try only printing data that has changed or changed by a threshold amount even though you keep track of the exact state.

I was thinking that a gyro as well as accelerometer might be better. The combo sells in standard modules for cars, tablets, etc. I'm waiting on a couple of those to arrive, ran me $5 ea.

No, that is more of Processing, it's another program that the arduino software was based off of. I personally don't use processing , so I don't know how to go about making a graph, but that is what you need to look into.