Adding more decimals to GPS data in Microsoft Arduino Virtual Shield

The default number of decimal places for the example named Basic-GPS for the Microsoft Arduino Virtual Shield is 2 decimal places. This means that the accuracy of the GPS position is not accurate by 500m to 700m from the right location.

The gps.Latitude and gps.Longitude value can be made more accurate by appending the number of desired decimal places as shown in the figure below. What changed from the original code is

String lat = String(“Lat: “) + String(gps.Latitude);
String lon = String(“Lon: “) + String(gps.Longitude);


String lat = String(“Lat: “) + String(gps.Latitude,6);
String lon = String(“Lon: “) + String(gps.Longitude,6);


The rest of the code are similar to the example, except I use serial.begin(9600) to match with my HC-06 bluetooth baud rate.

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.

Ceramah Asas Robotik di SMK Padang Kemunting

Hari ini saya telah dijemput untuk datang ke SMK Padang Kemunting, Kuala Terengganu untuk menyampaikan ceramah berkenaan Asas Robotik. Seramai 60 orang pelajar di kalangan penuntut Sains Tulen dan Perakaunan hadir. Ceramah ini juga turut dibantu oleh dua orang pelajar pasca-siswazah saya, Ahmad Israr Ihsan Mainong dan Tengku Hafidah Tengku Hussien. Kami mengakhiri ceramah pendek ini dengan memberi peluang kepada para pelajar untuk menerbangkan AR Drone di dalam perpustakaan SMK Padang Kemunting.


Penerimaan para pelajar dan guru adalah sangat memberangsangkan. Kami sempat beramah mesra dengan guru Kaunseling, Cikgu Fadhlina, guru Fizik, Cikgu Fauziah dan guru bahasa, Cikgu Aida. Kami difahamkan bahawa Cikgu Fauziah adalah sangat aktif dengan aktiviti pertandingan rekacipta kreatif dan inovatif. Pada tahun lepas, SMK Padang Kemunting berjaya merangkul Johan di pertandingan Sains dengan produk mereka, Kereta Solar.

Pada tahun hadapan, SMK Padang Kamunting akan menyertai pertandingan robotik, insyaAllah kumpulan penyelidikan kami, Ocean Robotics Group akan memandu pelajar-pelajar ini dan berkongsi kepakaran semoga mereka berjaya di dalam pertandingan ini.

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.

Arduino and Flash Interface

There are 4 main components needed to getting an Arduino to communicate with Flash:

  1. Code to run on the Arduino: This sends data over the USB virtual serial port.
  2. A Serial to Socket Server: This takes data from the serial port and sends it over a network socket. Designed to be used with any client software (Flash etc) and any microcontroller.
  3. A Flash Socket Library: Actionscript code in flash that accepts and interprets the data coming in from the network socket. You can do this yourself, but why? – most people use an existing codebase.
  4. Your Flash Code (and Sample code): You custom actionscript code that does something interesting with the data. Some resources have sample actionscript code so you can learn by example.


NOTE: All of this can also work in reverse – Flash can send data to Arduino.


Additional Resources:

  • Adobe Tutorials For Connecting Flash and Arduino : Adobe Software Evangelist Kevin Hoyt explains in a series of video tutorials the hardware and software stacks needed to connect Arduino with Adobe Flash usingSerProxy. His approach takes advantage of the powerful sockets features of Flash and a Serial-To-Sockets Module called SerProxy.
  • Interfacing Flash and Arduino, from scratch : A complete tutorial from Jean-Philippe Côté on how to setup a working Flash/Arduino environment using the Arduino IDE, the FTDI driver, the Firmata sketch, as3glue and SerialProxy/TinkerProxy 2.
  • Getting Started with Flash and Arduino : An introductory tutorial written by Mike Chambers that shows how to set up Arduino,TinkerProxy and Flash to communicate with each other. The example code shows how to send and receive information between Flash and Arduino.
  • Getting started with the NETLab Toolkit A video and text that introduces using the NETLab Toolkit to connect Flash to Arduino – no code required.

Arduino.js prototype (JavaScript + Arduino interface)

The Hallowe’en season set the theme for this demo, of which I had a larger-scale variant running black lights and floodlamps for a party last weekend. In case it isn’t obvious, this is going to get really nerdy. Ready? Go.

In brief:

JavaScript is controlling volume and pan of music (via SoundManager 2) based on live analog data from potentiometers connected to an Arduino device. Canvas-based graphs at left show the data coming in from the pots (ranging from 0-1023); as an example of writing to the device, LED lights respond to music frequencies as reported from JavaScript.


I’ve been tinkering with a JavaScript wrapper for the “AS3Glue” Flash library in order to get a JS-based API for talking to Arduino devices. The JS talks to Flash, which talks to a socket/serial proxy program running on the host computer, which talks to the Arduino device over USB that is running “Standard Firmata” controller code. It’s a slightly Rube Goldberg-esque technology stack in order to pass bits back and forth, but it works. (TODO: Look at using WebSockets, which can eliminate the Flash layer.)

Analog and digital input pins can use onRecieveData-style event listeners, which is much more efficient than a polling-based approach; thus, you can be notified when a pin goes high or when an analog input changes. (The latter is always shifting slightly due to its nature, of course.)

Basic spectrum analysis data comes from SoundManager 2, and this is fed into a digital output for blinking one LED roughly in step with the bass line, and another PWM-style output (varying output voltages, thus varying LED brightness) with the rhythm.

I couldn’t be arsed to really sync the video with the screencast bit, so the LEDs look like they’re blinking a bit out-of-step.

Setup: Browser-based control, JavaScript <-> Flash 9 <-> Socket/serial proxy (“Processing” IDE running SerialNet example script at 115200 baud) <-> Arduino Uno (USB) device with “Standard Firmata” 2.0 + prototyping breadboard, LEDs etc.

I am running at an interval of ~25 fps here for updating the LEDs, and the socket/serial proxy + Arduino seem to be able to handle the data rate generated from this without issue.

A small code example (JavaScript):

arduino.onAnalogReceiveData = function(pinNumber, value) {
// we got some data from one of the pots connected to the Arduino
// and it will be between 0 and 1023
if (pinNumber === 1) {
var volume = parseInt(value/1023*100);
soundManager.setVolume(mySound, volume);

You can also write to digital output pins.

// Somewhat-related example: blink an LED on pin 13 using writeDigitalPin()

function blink(pin, value, delay) {
arduino.writeDigitalPin(pin, value);
setTimeout(function() {
blink(pin, !value, delay); // wait “delay” msec, then repeat
}, delay);

blink(13, 1, 1000);