Arduino > Flash range sensor experiment

I’ve been playing around with the Arduino electronics prototyping platform recently and this is my first experiment. It’s a prototype for a future artwork that essentially acts as a primitive touchscreen device. I’ve used 2 PING))) Ultrasonic Range Sensors positioned at the top of my monitor. These measure the distance of any object placed in front of them. The Arduino board collects this data and passes it on to Flash via SerProxy.

Click here to see the video on Vimeo
Click here to see the video on YouTube

For this project I used a modified version of David Cuartielles’ Arduino sketch and SerProxy as a Serial-to-Network Proxy Server. Here is my serproxy.cfg code.

# Config file for serproxy
# See serproxy's README file for documentation

# Transform newlines coming from the serial port into nils
# true (e.g. if using Flash) or false

# Comm ports used

# Default settings

# Idle time out in seconds

# Port 3 settings (ttyS2)

I spent quite a lot of time trying to use Firmata, and AS3Glue but found that Firmata didn’t work with the PING Range Sensor. I’m fairly sure that AS3Glue requires the Board to be running Firmata so, as mentioned above, I settled for Arduino code from David Cuartielles. I wrote my own Actionscript to deal with the incoming data using the Socket and ByteArray classes. You can find an early rough version of this code here.

Images of the setup can now be seen here.


21 Responses to “Arduino > Flash range sensor experiment”

  1. 1 Alex June 7, 2008 at 8:53 am

    Hi James,
    that looks great! Easy and cheap to build. I have two questions, how precise is it? And do you have to use three sensors to cover the whole screen?

  2. 2 jamesalliban June 8, 2008 at 10:21 pm

    Thanks very much.

    The range sensor is not overly accurate. There was a bit of a difference between the two. If I place a book 20cm under them both, one will read 20cm and the other 24cm. With regards to your second question, I’m hoping to eventually have about 10 sensors and the screen will be replaced by a projection on a wall. I will also be looking into using triangulation to find the position of the user’s hand. This will hopefully require only 3 sensors.

  3. 3 ilya July 7, 2008 at 3:42 am

    wow nice!
    Love the particles too 🙂
    it would be col if youd change the particles styles, and im sure you can.
    still, cool

  4. 4 Kristofer Forsell October 26, 2008 at 2:09 pm

    Very nice!
    I thought I ought to let you know that you code has been a great help for a school project at Hyper Island. You can have a look here at a short project brief.

    Many thanks for sharing your wisdom.

  5. 5 jamesalliban October 27, 2008 at 11:10 am

    Glad to have been of help. Good luck with the project.

  6. 6 Ribeiro Santos November 25, 2008 at 6:08 pm


    Great job! I have just one question: how do you detect you have touched the “button”?

    Thanks for sharing your project,
    Ribeiro Santos

  7. 7 jamesalliban November 26, 2008 at 2:55 pm

    Thanks Ribeiro. I specified distances for each range sensors. If the distance between the sensor and an object (in this case my finger) is between, say, 15 and 20 cm, this registers as a button press.

  8. 8 kumar buddha November 27, 2008 at 3:42 pm


    Great and nice job…… can u suggent me how to do this in flash?

    if posible…

    kumar buddha

  9. 9 jamesalliban November 28, 2008 at 11:27 am

    There are links to the code required to build this in the post. You can find the info here –

  10. 10 richard November 29, 2008 at 4:15 pm

    hey james

    i have 2 pings as well but am having problems, i have adapted some code and can get the data from 1 ping through arduino into the software i am using, but when i adapted it for two sensors i seemed to have some problems, such as even if i set different delay times for the low high low pulses for each sensor, when i compile the code both the pings flash at the same time and are very erratic for instance when i move my hand back and fourth the act light seems to go faster and slower and sometimes just go crazy and i get scarred for the life of my duino, do you know how to solve this problem? any help would be greatly appreciated.



  11. 11 jamesalliban December 3, 2008 at 10:42 pm

    Hi Richard. As promised, I’ve just blogged images of the setup. Hope it helps.

  12. 12 Settor33 October 11, 2009 at 2:27 am

    Thanks a lotI consider this site a very good one for me to face the interview questions ahead of me. ,

  13. 13 jamesalliban October 13, 2009 at 10:19 am

    Glad to have helped. Good luck with the interview.

  14. 14 guitarboy April 13, 2010 at 8:59 am

    hey james

    Can you share this object’s fla file?
    I’ve tried many times, but I did not succeed.
    I really really want to try this.
    I hope you can help me.
    Thanks a lot!!

  15. 15 P. Fnord July 9, 2010 at 6:33 pm

    Great project! I have tried this as well with optical distance sensors, but they seem to interfere with each other when they face each other or are aligned in a rectangular angle to earch other. Have you had the same problem with the sensors you used?

    …and there’s a little typo: “[…] the Arduino microcontroller […]” is in fact an atmega avr microcontroller – arduino is just the prototyping board around it 😉

  16. 16 jamesalliban July 11, 2010 at 3:47 pm

    Thanks P.Fnord. I didn’t get that problem but I noticed the values were out by a few cms on one of the sensors.

  17. 17 kailash June 23, 2012 at 12:17 am

    Hi Guys,
    Nice that you guys are working on the same sensors as I do.. I wanted some help if any one could with my sensors. I have programmed PING UltraSonic sensor with Arduino Duemilanove to detect an object while in motion. Sometimes, it detects and sometimes not. Also to mention, I need to detect the swinging object, so its pretty fast. Can anyone help me out with this code!!!

  1. 1 Touch screen using range sensors - Hack a Day Trackback on July 7, 2010 at 10:01 pm
  2. 2 Touch screen using range sensors | Geoff Hatch Technology Resource Trackback on July 7, 2010 at 10:50 pm
  3. 3 Touch screen using range sensors | Video Game News, reviews, and information. Trackback on July 8, 2010 at 12:20 am
  4. 4 touchless touchscreen « arch 430 | networked technologies Trackback on May 8, 2011 at 6:51 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


  • RT @ShaunKing: URGENT. My friends in Standing Rock just sent this to me & asked me to share it. They are surrounded by militarized police… - 3 days ago
  • My wife visited a website on Friday. Today a brochure from the company arrived in the post. She didn't create an account. Is that a thing? - 2 weeks ago
  • "Yesterday I was clever, so I wanted to change the world. Today I am wise, so I am changing myself." Rumi - 3 weeks ago
  • Most interesting chart I've seen in a while.… - 3 weeks ago
  • Getting bored of saying (and hearing) his name. From now on I will refer to him as bubba. Seems like an appropriate sound. - 3 weeks ago

Flickr Photos




More Photos

%d bloggers like this: