Interface & Application Programming
For my final project, I'd like to use a mobile app or an GUI for PC/MAC to adjust the target value of sensors and displays. This week I will try mobile app option with MIT App Inventor 2.
I modified the Satshakit a bit to make it more easy to use with HC-05 bluetooth module and USB-UART breakout (can work with FTDI FT232 or Chinese CH430 series boards). Also I added a pair of 4.7k resistors between pin 4/5 of elenakit and VCC as pull-up resistors for I2C. To enable the I2C feature, just simply put a jumper cap on the pins close to the pull-up resistors. Say goodbye to breadboard and messy wires!
You can save the pngs above to fab them with fab module directly.
And this is how it works like.
You can download the file for elenakit here (Eagle files): .sch .brd
When it comes to the fastest ways to create a mobile app, App Inventor must be on that list. It provides simple graphic programming solution for building an Android app.
App Inventor used to be a stand alone offline software. Now for the App Inventor 2, it is fully web-based, try it here.
Logged in with any Google account, you can see your project list. It is composed of two parts, one for interface design - designer, another for prgramming - block.
For my first try with App Inverntor + Arduino, I did something very simple and similiar to my exercise on last week. That is connecting the HC05 bluetooth module to Satshakit, and the Android phone will send characters to HC05, which commands the Satshakit to switch the LED on pin 13 on and off.
Just like something I did last week:
The app came with a very simple interface:
App program design:
on the Satshakit side:
#include <SoftwareSerial.h>
#include <Wire.h>
SoftwareSerial blueToothSerial(0, 1); //default TX/RX
void setup() {
Serial.begin(9600);
blueToothSerial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
byte cmmd[20];
int insize;
while(1){
if ((insize=(blueToothSerial.available()))>0){
Serial.print("input size = ");
Serial.println(insize);
for (int i=0; i<insize; i++){
Serial.print(cmmd[i]=char(blueToothSerial.read()));
Serial.print(" ");
}
}
switch (cmmd[0]) {
case 1: //send "1"
digitalWrite(13,HIGH);
break;
case 0: //send "0"
Serial.println("Get 0");
digitalWrite(13,LOW);
break;
}
}
}
You can also download the codes below:
App Inventor 2 (in .aia format)
For my final project, the plan now is try to adjust or control at least 2 sensors from the app, so I need to do some further studies upon that. The other thing I will really liked to try is how to send data to Android phone instead of just receive data from it. I will try to figure out how to do that in the future.