Measure distance using ping sensor and display it using Lumia 430 (Windows Virtual Shield)

On the next journey of tinkering with Windows Virtual Shield, I combined the use of ping sensor to measure distance and attempted to display the distance using Lumia 430 (Windows Virtual Shield).

Example codes that got ‘Frankensteined’ in this work are from the Ping Example and Windows Virtual Shield Example. Have a look below and see if you can replicate the same thing.


Hello World Windows Virtual Shield lessons learned.

I have been attempting to run Hello World code using my Windows 10 Phone (Lumia 430, price RM 179) since 4 days ago to no avail. After a while, I have managed to run a successful example from this video:

Some of the lessons learned:

Problem: The Windows Virtual Shield app downloaded via Windows Store freeze once the phone and bluetooth connected.
Solution: See link Download Visual Studio 2015, download the source code of Windows Virtual Shield and deploy the codes to the phone via Visual Studio 2015.

Problem: Screen remain blank after device connected within Windows Virtual Shield.
Solution: Use the Arduino code below. I’m suspecting that the function ‘refresh’ will help to re-render the screen hence show the Hello World text on the phone.

Problem: No data received / shown
Solution: Make sure the baud rate matched with the bluetooth specification. I’m using JY-MCU BT_BOARD V1.03. Its baud rate is 9600.

Migrated to Linode, Ubuntu 13.04 upgrade: php mkdir failed problem solved

I’m migrating my blog to my Linode VPS from a shared hosting. While most of the tutorials are very good, especially this part, I was struggling to install wordpress plugin, or any actions that require php to create directory.

It turns out that although the permissions, owner and group are all correct, in which pointed to the myusername, I still could not make my php to create directory to save its life. Until I found this in stackoverflow.

Basically what solved my problem was:
1. sudo nano /etc/apache2/envvars
2. Look for export APACHE_RUN_USER=www-data and export APACHE_RUN_GROUP=www-data
3. Change it to APACHE_RUN_USER=myusername and export APACHE_RUN_GROUP=myusername
4. Save and quit
5. Restart apache

Now I can enjoy my nice Linode VPS happily.

Updating Ubuntu Server via SSH

If you’re having a web server running on top of ubuntu, the update is easy.
In SSH, you’ll see something like this:

45 packages can be updated.
23 updates are security updates.

Simply type:

sudo apt-get dist-upgrade

It will request your password. Once you key in your password, your ubuntu installation shall be updated.

Testing DFRobot APC220 Radio Communication Module with Arduino Blink Example

I got my hands on the APC 220 Communication Module from DFRobot for our robotic fish project [1] .

In this test, I use the LED Blink example, modded to include the serial port reading. While in the LED Blink example, you can just hook the positive point of LED to Pin 13 and its negative point to ground (GND), while the additional connections for the APC 220 module are as below:

APC220 Arduino connection

As shown in the figure, the connections are simple since I just wanted to perform a simple test to see whether the module is working fine:

APC 220 Arduino Blink

Below are the codes. You are free to change the serial baud number, I used 57600. Once the codes were uploaded to your Arduino board,

  1. connect everything,
  2. pop in the Serial Monitor on your Arduino IDE console,
  3. choose the respective baud (mine is 57600),
  4. send capital H to the console, observe the LED is turned on,
  5. send other character e.g. i to the console, observe the LED is turned off.

Happy coding!

// Modified from Arduino Playground tutorial:
char val; // variable to receive data from the serial port
int ledpin = 13; // LED connected to pin 13 (on-board LED)

void setup() {
  pinMode(ledpin, OUTPUT);  // pin 13 (built-in LED) as OUTPUT
  Serial.begin(57600);       // start serial communication at 57600bps 
void loop() {
  if( Serial.available() )       // if data is available to read
    val =;         // read it and store it in 'val'
  if( val == 'H' )               // if 'H' was received
    digitalWrite(ledpin, HIGH);  // turn ON the LED
  } else { 
    digitalWrite(ledpin, LOW);   // otherwise turn it OFF
  delay(100);                    // wait 100ms for next reading

[1] I have established a research group named Marine Robotics Research Group. Someday I’ll make some write up for it.

Using COM Automation to quick-start Bentley Maxsurf v18

The latest version of Maxsurf is Bentley Maxsurf V18i. You can download this version from Formsys and Bentley site, in which you’ll get a 15-days fully functional trial version. Afterwards, you can purchase the license via Bentley Select Licensing. If you’re from Malaysia, you can get the license from Caidmark Sdn Bhd.

Okay let’s jump into the good stuff. If you are using the Trial Version, you’ll be:

1. Notified each time by a pop-up which check your license’s status,

2. clicking the trial button,

3. clicking the selection of hull and,

4. finally arrive at the design space.

An awesome person (like you and me) will definitely automate these actions and go fishing. The step will be shorten to:

1. Clicking our newly-made programme, and
2. Voila there goes our design space!

You’ll be using Autoit V3. Make sure you get familiar with the software (approximate time: 10 minutes). It is basically a programme to automate your action in Windows. However you can also use it to write complex programme. It’s basically based on BASIC programming language. (Wow, 2 puns in one paragraph!)

1. First, you’ll need to copy-paste the codes below. Take note that the path of my Bentley Maxsurf is default.

2. Save it somewhere in a folder (not in the desktop, Windows permission doesn’t like this behaviour, Windows will probably kill your cat).

3. Compile it to EXE (using AutoIt compile function)

; Maxsurf Start
; by: Dr. Ahmad Faisal Mohamad Ayob
; 21 July 2012

; Initiate COM object of Maxsurf within our programme
$oMaxsurf = ObjCreate("Maxsurf.Application")

; Run EXE path of Maxsurf Modeler Advanced 64 bit
Run ("C:Program FilesBentleyEngineeringMaxsurf 18 V8iMaxsurfModelerAdvanced64.exe")

; Wait for Licensing Options -> Choose default (Trial) and send {Enter}
WinWaitActive("No License Found")
Send ("{ENTER}")

; Wait for Maxsurf Quick Start hull options and send {ESC} to invoke the default design space
WinWaitActive("Maxsurf Professional Quick Start")

Voila! You’ve just finished your first automation programme! (Well technically it’s mine, but I gave it to you, you’re welcome).

What we are expecting is, once you clicked your programme, it will do all the clickity-clack above and brings you the design space.

Happy coding!

p/s: You want to have the final compiled EXE? Grab it here.