We have presented this segment some good news. Who likes to know that Arduino is an infinite world of possibilities, from the simplest to the most complex and daring. That is what we today show. A project developed by our readers, Ricardo Sousa and Diogo Pinho and showing a bolder arm of the Arduino.
In this paper we develop a Bluetooth communication between a mobile phone with Android technology and a microprocessor Arduino board, adapted and developed to receive commands and executes them. This combination will be made in order to guide a small robot remotely via a mobile phone with Android technology.
To give life to the project, an application was developed to run on Android, with functions for sending and receiving data to an Arduino platform via a Bluetooth module.
The robot car was adapted and developed with some existing components in the market, and that we had in our possession, so that it was possible for him to move and react when they were sent to you some specific signals via a smartphone, making it a real-time simulation . See video at end of article!
Material used in this project
- 1 Arduino Nano V3.0
- Bluetooth 1 HC-05
- 1 Base 4 relays
- 1 Breadboard
- 2 DC motors
- 1 7.2V-2100mA Battery
- 1 7805
- 1 Freewheel
- 1 LDR
Arduino Nano V3.0
We used this version of an Arduino to have small and have enough memory and ports to the desired project.And you can connect a Bluetooth device to communicate with your phone.
Power
The Arduino Nano can be powered via the USB Mini-B connection or 5V external power supply (pino27).
The power source is automatically selected for the source of greatest tension. The FTDI FT232RL chip on the Nano is only powered if the card is powered via USB.
As a result, when running the (non-USB) external power, the 3.3V output (which is provided by the FTDI chip) is not available and the RX and TX LEDs will flash if digital pins 0 or 1 are high.
Memory
The ATmega328 has 32 KB, (also with 2 KB used for the bootloader).
Entrance and exit
Each of the 14 digital pins on the Nano can be used as an input or output, using pinMode (), digitalWrite (), and digitalRead ().
They operate at 5 volts. Each pin might provide or receive a maximum of 40mA and has an internal pull-up resistor 20-50 kOhms. In addition, some pins have specialized functions:
- Serial: 0 (RX) and 1 (TX). Used for the reception (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the FTDI USB-TTL Serial chip.
- External interrupts: 2:03 These pins can be configured to trigger an interrupt on a low value, a rising edge or falling, or a change in value.
- PWM: 3, 5, 6, 9, 10, 11 and provide an 8-bit PWM output with analogWrite () function.
- SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not included in the Arduino language.
- LED: 13. There is a built-in LED connected to digital pin 13 when the pin is of high value, the LED is on, when the pin is LOW, this LED is inserted on the board and external to the chip.
The Nano has 8 analog inputs, each of which has 10-bit resolution (1024 different values). By default they measure from 0 to 5 volts, though you can change the upper limit of their range using the analogReference () function.
Communication
The Arduino Nano has a number of facilities to communicate with a computer, another Arduino, or other microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). An FTDI FT232RL on the board channels this serial communication over USB and the FTDI drivers (included with the Arduino software) provide a virtual com port to software on the computer.
The Arduino IDE software includes a serial monitor which allows simple text data to be sent to and from the Arduino board. RX and TX LEDs on the board will flash when data is being transmitted by the FTDI chip and USB connection to the computer.
Serial software library allows serial communication in any one of the digital Nano pins.
The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino software includes a Wire library to simplify use of the I2C bus.
Programming
The Arduino Nano can be programmed with the Arduino software. The ATmega328 on the Arduino Nano comes with a bootloader that allows you to upload new code without the use of an external hardware programmer. It communicates with the original STK500 protocol. You can also bypass the bootloader and program the microcontroller through the ICSP (In-Circuit serial programming).
HC-05 Bluetooth
The HC-05 Bluetooth module enables communication between the Arduino and other Bluetooth devices via TTL Serial data transfer.
With this module you can control servos, motors, write text on an LCD, etc. This module is inserted and connected to the Arduino to enable us to communicate with the phone through a Bluetooth protocol created by us.
One of its advantages is to be small, light and robust with a fast and reliable communication (<10 meters = "" to = "" access = "" s = "" his = "" set = "" s = "" internal = "" to = "" the = "" name = "" a = "" display = "" pin = "" of = "" security = "" speed = "" communicates = "" we must = "" using = "" Command = "" t = "" p = "">).
For our project we have to use some of the following commands:
- AT -> Test the connection
- AT + VERSION -> To know the module version
- AT + ROLE = 1 -> Configure the module as MASTER (0 is Slave)
- AT + CMODE = 0 -> To connect to the last device (automatically)
- AT + INIT -> Initialize
- AT + INQ -> Find other Bluetooth equipment
- AT + INQC -> Complete search
- AT + RNAME -> Ask the name of a specific Bluetooth device (through its address)
- AT + FSAD -> Search this equipment in the module authentication list already authenticated before (if any)
- AT + BIND -> To link a product to the HC-05 module
- AT + PAIR -> Perform pairing of the desired equipment
- AT + LINK -> Connect
More information on the commands: See here.
Characteristics:
- Bluetooth v2.0 + EDR
- Operating mode Master or Slave
- Frequency: 2.4GHz ISM band
- Modulation: GFSK (Gaussian Frequency Shift Keying)
- Power: ≤4dBm, Class 2
- Sensitivity: ≤-84dBm at 0.1% BER
- Speed: Asynchronous 2.1Mbps (Max) / 160 kbps, Synchronous: 1Mbps / 1Mbps
- Security: Authentication and Encryption
- Profile: Bluetooth serialport
- Power supply: + 3.3VDC 50mA
- Ambient temperature: -20 ~ +75 C
- Dimensions: 28mm x 15mm x 2.35mm
Module 4 relays 5v
We use this project this module relays, since we do not have in "stock" any electronic components that made the H-Bridge work to control the motors, in which case the ideal component for this purpose.
This is a 4 5V relay module (AC250V 10A; DC30V 10A) capable of controlling multiple devices and equipment with large chains. This module can be controller directly by a microcontroller: Arduino, 8051, AVR, PIC, DSP, ARM, ARM, MSP430, TTL logic.
Characteristics
- Module 4 5V relays
- Equipped with 4 high-current relay: AC250V 10A; DC30V 10A
- Standard interface that can be controlled directly by a microcontroller: Arduino, 8051, AVR, PIC, DSP, ARM, MSP430, TTL logic
- 4 LED status indication of the relay output
- TTL control signal of 12V-3.5V
- There is a normally open contact and one normally closed contact
- The relay coil is driven by a transistor and not directly by the microcontroller.
- The pin pull-down circuit is to prevent fluctuations in relay
DC motor
These two devices are our sources of kinetic energy that allows us to move our car remotely.
When the Arduino ordered to move this statement to relay to open or close depending on what we want what gives us the freedom to move the remote controlled car in one direction or in the opposite direction, so in addition we shift in a straight line can maneuver the remote controlled car 360 ° around you because each engine and powered and controlled individually.
Characteristics:
- Operates between 3-6v
- Diameter 65mm
- 120rpm (6w)
- 100mA (3V), 120mA (6w)
- Reduction 1: 120
7.2V-2100mA battery
Battery to power all the equipment installed in the car.
This battery has a great autonomy allowing us to be long periods of activity with the equipment.
Voltage limiter 7805
We had to integrate this component, because according to the Arduino features nano can not use a voltage greater than 5v the external input of the Arduino, so this does not happen we put one 7805 to lower the voltage to 5V at the entrance as they have a battery that It provides us with 7.2V.
NOTE: Using this way the Arduino Nano should not connect the USB cable to program the Arduino while this connected external link, we can burn the equipment or the PC ports.
Free wheel
This component allows the car turn 360º freely and with less friction. So we can maneuver the car with the two motorizes wheels and ease of movement in tight places, or with little freedom of movement.
LDR
With this component we will check and send values via Bluetooth to the phone where we can see the brightness that the car is being subjected while it will move.
LDR (Light Dependent Resistor) has a feature that makes its resistance varies as the brightness incidida about it. This enables the use of this component to develop a sensor which is activated (or deactivated) when it focus on a certain brightness or use such data to vary a PWM may be attached to motors or lights, etc.
The LDR resistance varies inversely proportional to the amount of light incident upon it, that is, while the light beam is shining on it, the LDR offers a very low resistance, and when this beam is cut, its resistance increases.
Practical development
Hardware
Mounting below performed in software wiring diagrams, represented the schemes used in this project:
Below we can see a picture of the actual calls made between the various components:
Software
Arduino code
#include SoftwareSerial mySerial (0, 1);
// RX ports for communication, TX FOR Arduin
char state; // to store the amount received by bluetooth
/////// outputs statement to the Relay for mov motor control dc /
int LED = 8; // light robot presence
int MTR0 = 9; // output to the relay 0
int MTR1 = 10; // output for relay 1
int MTR2 = 11; // output for relay 2
int MTR3 = 12; // output to relay 3
int LEDst = 1;
// for reading LDR values connected to the analog port 5 const int analogInPin = A5;
int SensorValue = 0;
//
void setup ()
{// initialize the Serial ports for the terminal and the bluetooth for Initials
Serial.begin (9600);
Serial.println ("Start Bluetooth communication");
mySerial.begin (9600);
mySerial.println ("Start Bluetooth communication"); // declare the exit doors
pinMode (LED, OUTPUT);
pinMode (MTR0, OUTPUT);
pinMode (MTR1, OUTPUT);
pinMode (MTR2, OUTPUT);
pinMode (MTR3, OUTPUT);
// declare the initial state of the doors in }
// RX ports for communication, TX FOR Arduin
char state; // to store the amount received by bluetooth
/////// outputs statement to the Relay for mov motor control dc /
int LED = 8; // light robot presence
int MTR0 = 9; // output to the relay 0
int MTR1 = 10; // output for relay 1
int MTR2 = 11; // output for relay 2
int MTR3 = 12; // output to relay 3
int LEDst = 1;
// for reading LDR values connected to the analog port 5 const int analogInPin = A5;
int SensorValue = 0;
//
void setup ()
{// initialize the Serial ports for the terminal and the bluetooth for Initials
Serial.begin (9600);
Serial.println ("Start Bluetooth communication");
mySerial.begin (9600);
mySerial.println ("Start Bluetooth communication"); // declare the exit doors
pinMode (LED, OUTPUT);
pinMode (MTR0, OUTPUT);
pinMode (MTR1, OUTPUT);
pinMode (MTR2, OUTPUT);
pinMode (MTR3, OUTPUT);
// declare the initial state of the doors in }
void loop ()
{if (mySerial.available ())
{// IF communication available
state = mySerial.read (); // reads the value received by bluetooth,
// right /////////// //////////////////////////////
if (state == 'R' || state == 'r')
{digitalWrite ( MTR0, LOW);
digitalWrite (MTR1, HIGH);
digitalWrite (MTR2, HIGH);
digitalWrite (MTR3, LOW); }
// Left /////////////////////////////////////////
if (state == 'L' || state == 'l')
{digitalWrite (MTR0, HIGH);
digitalWrite (MTR1, LOW);
digitalWrite (MTR2, LOW);
digitalWrite (MTR3, HIGH); }
// Front /////////////////////////////////////////
if (state == 'F' || state == 'f')
{digitalWrite (MTR0, LOW);
digitalWrite (MTR1, HIGH);
digitalWrite (MTR2, LOW);
digitalWrite (MTR3, HIGH); }
// Behind /////////////////////////////////////
if (state == 'B' | | state == 'b')
{digitalWrite (MTR0, HIGH);
digitalWrite (MTR1, LOW);
digitalWrite (MTR2, HIGH);
digitalWrite (MTR3, LOW); }
// STOP /////////////////////////////////////////
if (state == 'S' || state == 'w')
{digitalWrite (MTR0, HIGH);
digitalWrite (MTR1, HIGH);
digitalWrite (MTR2, HIGH);
digitalWrite (MTR3, HIGH); }
Sensor reading // //////////////////////////////////
SensorValue = analogRead (analogInPin);
Serial.println (SensorValue);
// send to TERMINAL and BLUETOOTH value ////////////// On / Off light //////////////////// ////
if (state == '0')
{digitalWrite (LED,
LOW);}
if (state == '1')
{digitalWrite (LED,
HIGH);} ////////// ////////////////////////////////////////////////// /////////////////////
delay
(100);}}
{if (mySerial.available ())
{// IF communication available
state = mySerial.read (); // reads the value received by bluetooth,
// right /////////// //////////////////////////////
if (state == 'R' || state == 'r')
{digitalWrite ( MTR0, LOW);
digitalWrite (MTR1, HIGH);
digitalWrite (MTR2, HIGH);
digitalWrite (MTR3, LOW); }
// Left /////////////////////////////////////////
if (state == 'L' || state == 'l')
{digitalWrite (MTR0, HIGH);
digitalWrite (MTR1, LOW);
digitalWrite (MTR2, LOW);
digitalWrite (MTR3, HIGH); }
// Front /////////////////////////////////////////
if (state == 'F' || state == 'f')
{digitalWrite (MTR0, LOW);
digitalWrite (MTR1, HIGH);
digitalWrite (MTR2, LOW);
digitalWrite (MTR3, HIGH); }
// Behind /////////////////////////////////////
if (state == 'B' | | state == 'b')
{digitalWrite (MTR0, HIGH);
digitalWrite (MTR1, LOW);
digitalWrite (MTR2, HIGH);
digitalWrite (MTR3, LOW); }
// STOP /////////////////////////////////////////
if (state == 'S' || state == 'w')
{digitalWrite (MTR0, HIGH);
digitalWrite (MTR1, HIGH);
digitalWrite (MTR2, HIGH);
digitalWrite (MTR3, HIGH); }
Sensor reading // //////////////////////////////////
SensorValue = analogRead (analogInPin);
Serial.println (SensorValue);
// send to TERMINAL and BLUETOOTH value ////////////// On / Off light //////////////////// ////
if (state == '0')
{digitalWrite (LED,
LOW);}
if (state == '1')
{digitalWrite (LED,
HIGH);} ////////// ////////////////////////////////////////////////// /////////////////////
delay
(100);}}
This program was developed in the application APP Inventor2:
Android code
Here you can download the file to use the bridge App Inventor 2
Download: BT_Robot_RSDP.aia
Menu 1
Menu 2
Menu 3
Conclusion
In this work we found a difficulty level increased due to communication is done through a mobile phone with Android technology which required learning a new language to program an application that would allow us to communicate with remote-controlled car and so send orders to it move.
After much research and plenty of tests it was possible to develop a mobile application that allows us to send commands. In the same application also integrate the ability to read the values obtained by the LCD installed on the robot, thereby obtained a bi-directional communication.
We have created a code Arduino language to be able to execute orders, we set up and tested a prototype in order to simulate in real time and view the remote controlled car to move. We had some problems in creating the car due to the short amount of time and lack of materials but with some dexterity and creativity successfully completed the project we set ourselves: A car / will not controlled robot distance, through a smartphone movements.
Post a Comment