Augmented Reality Tutorial No. 5: Interaction using Arduino and Ultrasonic Sensor

posted in: Augmented Reality | 17

Little by little we’re moving to

In this Augmented Reality tutorial the scale of the 3D cube is changed in Augmented Reality environment using data acquired from an ultrasonic sensor distance measurements. This is a basic interaction with virtual content.

Download # Arduino Code (*.ino file)

Download # Processing Code (*.pde file)

Download # Hiro Marker (*.pdf file)

(Processing software itself is available to download here)

Download # Newest nyar4psg 2.0.0 library for Augmented Reality (*.rar file)

NOTE: Extract library and put nyar4psg folder to Processing libraries location as you can see in example here: “C:\Users\EdgarasArt\Documents\Processing\libraries”. If there are no libraries folder in Processing folder (in My Documents) – create it!

Upload Arduino code directly to your Microcontroller from website
If you want to integrate Arduino IDE into your website (as above) sign up here: codebender


17 Responses

  1. Luis Abraham Paque Hernández

    Good night!

    You’ve done a great job. Well, I want to do this in a school project. If I have some doubts, could I ask you? Where could I send you my doubts?

    Thank you so much.

  2. sonia

    GLException: method “glclearDepthf” not available
    I am getting this exception. Please suggest how to resolve this problem. Thank you in advance.

    • admin

      Sorry, haven’t stumbled upon this error, but did you use Processing 2.2.1? If not, I would suggest to use this version, not the newest.

  3. Loc

    Hey man great work but I keep getting
    Used proccessing 3 and 2.2.1
    When I click “Run” I have a grey window and that error .

    • admin

      Full screenshot of the error would be great. Use 2.2.1 version.

      • Loc

        does this help man ?

        java.lang.RuntimeException: java.lang.AssertionError
        at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(
        at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(
        at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(
        at processing.opengl.PJOGL.requestDraw(
        at processing.opengl.PGraphicsOpenGL.requestDraw(
        at Source)
        Caused by: java.lang.AssertionError
        at jp.nyatla.nyar4psg.PImageRaster.wrapBuffer(Unknown Source)
        at jp.nyatla.nyar4psg.MultiMarker$PImageSensor.update(Unknown Source)
        at jp.nyatla.nyar4psg.MultiMarker.detectWithoutLoadPixels(Unknown Source)
        at jp.nyatla.nyar4psg.MultiMarker.detect(Unknown Source)
        at AR5_CodeForProcessing.draw(
        at processing.core.PApplet.handleDraw(
        at processing.opengl.PJOGL$PGLListener.display(
        at jogamp.opengl.GLDrawableHelper.displayImpl(
        at jogamp.opengl.GLDrawableHelper.display(
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(
        at jogamp.opengl.GLDrawableHelper.invokeGL(
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$200(Unknown Source)
        at java.awt.EventQueue$ Source)
        at java.awt.EventQueue$ Source)
        at Method)
        at$1.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at Source)

        • admin

          Actually, not much, have you tried previous tutorials with processing? Did everything worked smooth?

          • Loc

            no actually ok I will give it a go with random one and write you back.

          • Marcos

            cant that be because of missing jre or something like that ? i have the same problem here, i didnt touch the code except to put resolution 640×480 and it gives me the same error and it runs the window but no camera :/ any ideas ?

          • admin

            Did you put nyar4psg library in my docs/processing/libraries?

          • loc

            I made it work, in processing
            myPort = new Serial(this, Serial.list()[0], 9600); /
            I changed 1 with 0 and it worked

  4. Marcos

    yes, i have a runing AR app and it works just fine but then this example doesn’t work

  5. Marcos

    I’m using arduino uno, but i connected the same ports, 2,3 5v and ground and i can get reading on the arduino ide just fine so i think thats not the problem

    • admin

      How many ports do you have in the device manager? Which one from the top is arduino port (the first one, second one etc.)?

      • Marcos

        The arduino is not the problem because i can upload the program and get the readings from the sensor just ok …

        • loc

          myPort = new Serial(this, Serial.list()[0], 9600); /
          I changed 1 with 0 and it worked

Leave a Reply

Your email address will not be published. Required fields are marked *