Networking and communications

The assignment for this week was to build a wired &/or wireless network with at least two nodes. There are a lot of kind of communications but at this moment I am especially interested in the communication wireless by bluetooth. Some time ago I wanted to do a simple Android application to move everything. One of the challenges of my final project is to move a platform driven by motors with the mobile so this week has been a big oportunity for me to began with this task.



Another objective that I wanted to do was to define what kind of main board I will use in my final project, to control the motors. So I decided to test the Barduino board, recently improved by Luciano. Is a small board with the same Arduino Uno microcontroller, Atmega328P.

Arduino UNO vs Barduino:
To connect my mobile with the Barduino I've used RN-41 module bluetooth. It's very simple to use. You can buy it integrated in a small board, as I show in the picture, to facilitate the connexions. There are two possible connexions as you can see in his datasheet. I've decided to follow the intructions of Header B. I connected pin 1(RX) to pin 0 Barduino(TX) and pin 2 (TX) with pin 1 Barduino(RX). 5V power supplied by the Barduino and crossed pins 3 and 4 (RTS,CTS). I also removed R6 and R8.

This time I have installed a version of iteadstudio application for my mobile. It is a simple application that works very well for testing bluetooth devices.

I started to make my application to control the platform of my final project. I established communication with the board but I still have yet to solve a lot of errors :(

This is the code to test the comunnication with my board. When the board receive data, the data are displayed on the screen. If the data sent is a "1" (symbol) through mobile, the board receive a 49 decimal and the green led turns ON. When you send a "2" (symbol) green led turns OFF.

Code:
//----------------------------------------------------------------------------
//Barduino to Android first test
//Control of Barduino board by bluetooth
//----------------------------------------------------------------------------
//Juan Ranera, FabLab 2013
//Assignment: Networking and communications
//Barcelona, May 2013
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------


#define Led_ON 49    //49 DEC -> 1 Symbol when we sent 1 (Symbol) 
//corresponds to 49 (Decimal) according to the ASCII table
#define Led_OFF 50   //50 DEC -> 2 Symbol

/////////////////////////////////////////////////////////////////////////////
////////////////////// GLOBAL VARIABLE DECLARATION //////////////////////////
/////////////////////////////////////////////////////////////////////////////
int incomingByte = 0;	// for serial input data 
int led = 13;


void setup() {
	Serial.begin(115200);	// opens the serial port, set the speed to 115200 bps
        pinMode(led, OUTPUT);
}

void loop() {

        //digitalWrite(led, LOW);
	//send data only when you receive data:
	if (Serial.available() > 0) {

		//read the incoming byte: 
		incomingByte = Serial.read();
		//shows value received
		Serial.print("Barduino received: ");
		Serial.println(incomingByte, DEC);
        }
                if(incomingByte == Led_ON) digitalWrite(led, HIGH);
                if(incomingByte == Led_OFF) digitalWrite(led, LOW);
}



In the next video you can see the communication between Barduino and the mobile.