3rd May 2015 - Milling my board
I milled out my board and made a stupid error. I changed the traces of my design and forgot to update the cut file. Hence some of the traces were cut away and I had to solder on two wires as jumpers.
To ensure that the board was working I uploaded the blink sketch from the arduino environment. This worked so I set on trying to connect the circuit to my computer. I took the code given in the tutorial used my the other fab academy student I mentioned and adjusted it accordingly:
#include <SoftwareSerial.h> //Software Serial Port
#define RxD 3
#define TxD 2
#define DEBUG_ENABLED 1
SoftwareSerial blueToothSerial(RxD,TxD);
int led1 = 7;
int led2 = 6;
int led3 = 8;
void setup()
{
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
}
void setupBlueToothConnection()
{
blueToothSerial.begin(9600); //Set BluetoothBee BaudRate to default baud rate 38400
blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
blueToothSerial.print("\r\n+STNA=HC-05\r\n"); //set the bluetooth name as "HC-05"
blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
delay(2000); // This delay is required.
//blueToothSerial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
blueToothSerial.print("bluetooth connected!\n");
delay(2000); // This delay is required.
blueToothSerial.flush();
}
void loop()
{
char recvChar;
while(1){
//check if there's any data sent from the remote bluetooth shield
if(blueToothSerial.available()){
recvChar = blueToothSerial.read();
if(recvChar == '1'){
digitalWrite(led1,LOW);
delay (1000);
}
else{
digitalWrite(led1,HIGH);
}
}
}
}
I uploaded this and connected the bluetooth module to my computer as you would with any other device:
I then opened the serial communication window in the arduino environment. Ensure it is set to the correct port.
Now this is done you can open the serial communication window in arduino and talk to the board. In the code it should send a message to the window saying "bluetooth connected!". Unfortunately for me this wasn't the case. The message didn't appear and if I typed in the command to turn the LED on, nothing would happen.
The most probable cause was that I had assigned the wrong RX and TX ins in my code. I went back to my design file and double checked. I turns out they were the wrong way around. It is important to remember that the TX of the controller should be connected to the RX of the bluetooth module (and vice versa).
I corrected this, uploaded the code and voila! The serial window said "bluetooth connected!".
After many attepmts to send commands, I still wasn't able to control the LED. Time to sleep on it and come back to it tomorrow!