Interface and Application Programming

Group Assignment * Compare as many tool options as possible. Group Assigments from this link

Individual assignments In this assignment I have to: * Write an application that interfaces a user with an input &/or output device that I made

In this assignment I used HC-05 Bluetooth Module to control my circuit via mobile application. I read This Tutorials and it was very helpful. HC-05 Bluetooth Module: HC-05 Bluetooth Module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup. Its communication is via serial communication which makes an easy way to interface with controller or PC. HC-05 Bluetooth module provides switching mode between master and slave mode which means it able to use neither receiving nor transmitting data.

w15_2

To know more about this module you may read this data sheet. HC-05 Technical Specifications: • Serial Bluetooth module for Arduino and other microcontrollers • Operating Voltage: 4V to 6V (Typically +5V) • Operating Current: 30mA • Range: <100m • Works with Serial communication (USART) and TTL compatible • Follows IEEE 802.15.1 standardized protocol • Uses Frequency-Hopping Spread spectrum (FHSS) • Can operate in Master, Slave or Master/Slave mode • Can be easily interfaced with Laptop or Mobile phones with Bluetooth • Supported baud rate: 9600,19200,38400,57600,115200,230400,460800. Pin Definition:

w13_4

Pin Description Function
VCC +5V Connect to +5V
GND Ground Connect to Ground
TXD UART_TXD, Bluetooth serial signal sending PIN Connect with the MCU’s (Microcontroller and etc) RXD PIN.
RXD UART_RXD, Bluetooth serial signal receiving PIN Connect with the MCU’s (Microcontroller and etc) TXD PIN.
KEY Mode switch input If it is input low level or connect to the air, the module is at paired or communication mode. If it’s input high level, the module will enter to AT mode.
HC-05 Default Settings: Default Bluetooth Name: “HC-05” Default Password: 1234 or 0000 Default Communication: Slave Default Mode: Data Mode Data Mode Baud Rate: 9600, 8, N, 1 Command Mode Baud Rate: 38400, 8, N, 1 Default firmware: LINVOR Programming:
#include (SoftwareSerial.h)

SoftwareSerial blueToothSerial(2,3);
int c = 0;

void setup() {
 blueToothSerial.begin(9600); 
 pinMode(0, OUTPUT); 
 pinMode(4, OUTPUT);
}

void loop() {
c = blueToothSerial.read();  
if(c == 1) 
 {digitalWrite(4, HIGH);      
  digitalWrite(0, HIGH);
  delay(500); }

else if (c == 0) 
{digitalWrite(4, LOW);
 digitalWrite(0, LOW);
 delay(500);}    // turn the LED OFF by making the voltage LOW

else{}    
} 
After programming the circuit, it is the time to design an application to control the circuit via bluetooth. In fact there are many softwares for applications design, I used MIT App Inventor for my application. MIT App Inventor: MIT App Inventor is an intuitive, visual programming environment that allows everyone – even children – to build fully functional apps for smartphones and tablets. Those new to MIT App Inventor can have a simple first app up and running in less than 30 minutes. And what's more, blocks-based tool facilitates the creation of complex, high-impact apps in significantly less time than traditional programming environments.

w15_3

To use App Inventor you must have a google account:

w15_4

After that a new window appears, from my project select "start new project".

w15_4

After that, a mobile phone window appears and you can see the tool and settings you need to design your application user interface window. For more details you may read App Inventor Tutorials

w15_6

After complete my design it looks like:

w15_7

Click on BLOCKS on the right corner to start programming:
w15_9 w15_9
To test the application on the mobile phone you need to install "MIT AI2 Companion" on your phone. This application allows us to run the program and test it without need to download. More details you may find in this link
w15_10 w15_11
I read this tutorial which was helpful about bluetoot in appinventor. Finally I teste both of code and application to control a relay via bluetooth:

My application file: Arduino Code: