interface and application programming

week_15

assignment

Individual assignment: write an application that interfaces with an input and/or output device that you made group assignment: compare as many tool options as possible

experimentation

make it happen

For this weeks assignment I wanted to make an app with what you can control the light color. So I jumped on the https://thunkable.com/#/

#thunkable

#thunkable

#thunkable

#thunkable

#thunkable

#thunkable

#thunkable

Node MCU v3 with LED Ring connected with micro USB. #testingsetup

Node MCU v3 with LED Ring connected with micro USB. When I say green you make it light on the green #testingsetup #worked

Installing and running Thunkable on the iPhone. #testing

After I wanted to connect it with my final project too, but there was some issue with my Node MCU v3 what I was not able to resolve, so I decided to test simple python script creating an app for on/off of the lamp. I found this example tutorial very useful to follow up. Since I already had installed, arduino, I just connected the board from my final project to my comp. had to list usb port where is it connected by typing following to the terminal:

ls /dev/tty.usb*

save python code somewhere and run using

python file.py

Python code:

# -*- coding: utf-8 -*- import serial from Tkinter import * def ledOn(): # this is how you define functions in Python. ledOn() is executed if onButton is pressed arduinoSerialPort.write('a1') # sends ‘a1’ to the Arduino def ledOff(): # this is how you define functions in Python. ledOff() is executed if offButton is pressed arduinoSerialPort.write('a0') # sends ‘a0’ to the Arduino arduinoSerialPort = serial.Serial('/dev/cu.usbserial-FT9P01IV', 9600, timeout=1) appWindow = Tk() #creates the application window appWindow.wm_title("LED Control") #displays title at the top left var = IntVar() onButton = Radiobutton(appWindow, text="LED ON", variable = var, value = 1, command=ledOn) onButton.pack( anchor = W ) offButton = Radiobutton(appWindow, text="LED OFF", variable = var, value = 2, command=ledOff) offButton.pack( anchor = W ) appWindow.mainloop() # main loop. From here, the GUI starts updating and responding to user inputs.

Than open Arduino and put there following code:

#include <SoftwareSerial.h> SoftwareSerial mySerial(0, 1); int led = 2; // give a name to our LED int ledStatus; // status of the LED. It’s either HIGH or LOW (0 or 1) void setup() { pinMode(led, OUTPUT); // initialize the digital pin as an output. mySerial.begin(9600); // begin serial communication at 9600 baud } // main loop begins void loop() { if(mySerial.available() > 0) { // see if there is incoming data ledStatus = mySerial.parseInt(); // parse the data and store the first integer, if available, into our variable. digitalWrite(led, ledStatus); // Turn ON or Turn OFF the LED as per user input } }

of course I had to make a changes to it to communicate with my board. so than it looked like that:

#include <SoftwareSerial.h> #include <FastLED.h> #define NUM_LEDS 13 #define LEDSTRIP_PIN 8 CRGB leds[NUM_LEDS]; SoftwareSerial mySerial(0, 1); int led = 4; // give a name to our LED int ledStatus; // status of the LED. It’s either HIGH or LOW (0 or 1) void setup() { LEDS.addLeds<WS2812,LEDSTRIP_PIN,RGB>(leds,NUM_LEDS); LEDS.setBrightness(100); pinMode(led, OUTPUT); // initialize the digital pin as an output. mySerial.begin(9600); // begin serial communication at 9600 baud } // main loop begins void loop() { if(mySerial.available() > 0) { // see if there is incoming data ledStatus = mySerial.parseInt(); // parse the data and store the first integer, if available, into our variable. if(ledStatus == 1){ static uint8_t hue = 255; // First slide the led in one direction for(int i = 0; i < NUM_LEDS; i++) { // Set the i'th led to red leds[i] = CHSV(hue, 0, 255); // Show the leds FastLED.show(); // now that we've shown the leds, reset the i'th led to black // leds[i] = CRGB::Black; //fadeall(); // Wait a little bit before we loop around and do it again delay(10); } } else{ static uint8_t hue = 255; // First slide the led in one direction // mySerial.println("ON"); for(int i = 0; i < NUM_LEDS; i++) { // Set the i'th led to red leds[i] = CRGB::Black; // Show the leds FastLED.show(); // now that we've shown the leds, reset the i'th led to black //fadeall(); // Wait a little bit before we loop around and do it again delay(10); } } } }

#simple interface with buttons

#image - light ON

#video demonstration - first with one LED. this was first test. (The other LED is signal that the board is powered).

#3 The aim is to create an augmented reality option to display the virtual object of the lamp within the existing environment. For an interface application, I wanted to make an app with unity/vuforia using image target as a tracking option. The idea was to create a possibility for an end user to place the lamp in the wished position within the interior and to check if it fits the composition of an existing situation.

(Image from my thesis as na proof) And since I already had some experience with creating a similar strategy back in 2016 while working on my master thesis (see image) I wanted to follow up the same strategy. Unfortunately I was facing SW issues, had to reinstall unity again and the new unity was not able to open my old file. Now there is an upgrade - unity hub, thanx to this you can install any older version.

And since I didnt open unity for some time I needed to refresh my skills. I decided to revisit some tutorials for getting back to the process so I tried to follow this links: this link this link this linkIt was needed to install all necessary plugins too.

Than I placed simple 3D object - cube to the environment as a test, saved to the assets folder. It started to build and install iPhone player.

This process created in the same folder an xCode file, open it and follow filling out necessary fields. Dont forget to sign and put yourself as a team. otherwise it would scream an error. Modify the deployement info for wished target device, in my case it was iPhone with the latest iOS update. Connect iPhone with the cable, Run to Play and it creates the app in your phone. OK. this wuick test worked.

Than I wanted to jump on creation of image tracking AR with unity. on the vuforia developer portal https://developer.vuforia.com you upload the image with what you would like to track the app. Upload it, get the licence...

Compiling the database...takes a while...

Allow Unity to use the front camera for testing.

Now just place the target image in the field of view of the camera and wait till the object appears! So this was proove that my app was working. For saving the forest I decided to not print it out, just used my phone screen to display tracking image in order for achieving augmentation on it. success. Now I wanna replace the geometry with my own object.

Replaced for my geometry lamp shell. WORKED! YES!

Build and Run to push it to xCode to make it in your phone...the same process as previously.

Of course you need to verify the app in your phone. So go to the Settings/General/Device Management and allow the developer app verification.

After that you can see the apps in your phone, so open them and use it!

download files

keywords

_languages_device interfaces_data interfaces_user interfaces_graphics_multimedia_VR/AR/MR/XR_math_performance_deploy_

useful links

FabAcademy 2019_schedule