Architecture

FABLAB WINAM 2019

Fablab Winam 2019

INTERFACE AND APLICATION PROGRAMMING

Assignment

write an application that interfaces a user with an.
input &/or output device that you made.

Materials

1.Attiny 85 board
2.Jamper wires
3.Bluetooth module
4.LED
5.Andriod phone
6. Internet connection (for google voice)

Bluetooth module

Designing

1. Go to http://ai2.appinventor.mit.edu
2. Create all the necessary account and password.
3. Go to Project and start a new project
4. In the Design screen, you will see the depiction of an Andriod device screen.
5. Start by drag n drop user interface onto the screen.
6. Go to the blocks and add in the program logic.
7. Save the project.
8. Go to build app and select provide qr code for apk
9. Upload apk to Andriod phone to try,

My application

I want my app to control a LED via bluetooth. I have the option to use the button or my voice to give command.

My program

App Inventor 2

1. First I want to check if bluetooth is turn on when the program loads. If it is not, there will be a message to remind the user.
2. When the user click pair device, the list of bluetooth available will be displayed.
3. If it is the first time pairing, the phone will prompt for password. The default is 1234.
4. The disconnect button is to disconnect the bluetooth.
5. The status will show either connect to disconnected.
6. The Red, Green, Blue and power off buttons will send the respective commands when pressed.
7. Adding voice

Attiny 85 programing

I modified from the previous program that I did during the output week.
I have to set up the serial communication for the bluetooth and the code to activate the commands.
String voice; //value sent over via bluetooth
int redPin= 3;
int greenPin= 4;
int bluePin= 0;
int rx=2;
int tx=1;
SoftwareSerial mySerial(rx,tx);
void setup() {
mySerial.begin(9600);
pinMode(redPin, OUTPUT);
pinMode(rx,INPUT);
pinMode(tx,OUTPUT);
}
void loop() {
while (mySerial.available()){ //Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = mySerial.read(); //Conduct a serial read
// if (c == '#') {break;} //Exit the loop when the # is detected after the word
voice += c; //Shorthand for voice = voice + c
}
if (voice.length() > 0) {
mySerial.println(voice);
//----------Turn On One-By-One----------//
if(voice == "red") {setColor(255, 0, 0);}
else if(voice == "green") {setColor(0, 255, 0);}
else if(voice == "blue") {setColor(0, 0, 255);}
else if(voice == "power off") {setColor(0, 0, 0);}
//-----------------------------------------------------------------------//
voice="";}} //Reset the variable after initiating
void setColor(int red, int green, int blue)
{
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}

attiny



button file



apk