0% found this document useful (0 votes)
58 views5 pages

Reading Ultrasonic Sensor Data To FireFly

Reading Ultrasonic Data to Firefly details scripting in Arduino IDE to Firefly Plugin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views5 pages

Reading Ultrasonic Sensor Data To FireFly

Reading Ultrasonic Data to Firefly details scripting in Arduino IDE to Firefly Plugin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Food Living Outside Play Technology Workshop

Reading Ultrasonic Sensor Data to FireFly


by chris.kelusak on October 9, 2014

Table of Contents

Reading Ultrasonic Sensor Data to FireFly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: Reading Ultrasonic Sensor Data to FireFly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: Loading the Firefly Firmata onto your Arduino Uno . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 2: Connecting the Ultra Sonic Sensor to you Arduino Uno . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 3: Starting your sketch and Opening a Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Step 4: Reading from the Arduino Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 5: Converting to a different Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

http://www.instructables.com/id/Reading-Ultrasonic-Sensor-Data-to-FireFly/
Author:chris.kelusak author's website
Hello everyone, Thanks for checking out my work on here. I am a Graduate Architecture student at the Academy of Art University in San Francisco currently
working on my thesis. I am looking at ways of creating minimal surface geometries and how they can be used within architecture... More info to come as well as
a link to more work. Chris

Intro: Reading Ultrasonic Sensor Data to FireFly


This Instructable will be looking at how to configure a Ultrasonic Sensor using Arduino and Firefly for the purpose of detecting an objects distance and either changing
geometry within Rhino and eventually how to use the data for clash detection within an autonomous machine.

What you need:

Rhino 5
Grasshopper 3D Version 0.9.0075
Firefly Version 1.0.0.68
Arduino
Firefly Firmata
Arduino Uno
Breadboard
USB A to B
3 Jumper wires
Ultra Sonic Sensor (I used RadioShack® Ultrasonic Range Sensor but any will work)

File Downloads

Tutorial.gh (15 KB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Tutorial.gh']
Step 1: Loading the Firefly Firmata onto your Arduino Uno
1. Loading the Firefly Firmata_ Ping onto the Arduino Uno
1. Connect the Arduino Uno to your computer and launch the Arduino software
2. Open the Firefly Firmata into the Arduino software and upload it to your Arduino Uno.
3. Not what port your Arduino Uno is connected to by going to:
Tools > Serial Port
Close the Arduino Software

File Downloads

Firefly_Firmata_ping.ino (8 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Firefly_Firmata_ping.ino']
Step 2: Connecting the Ultra Sonic Sensor to you Arduino Uno
What you'll need:

Arduino Uno
Ultra Sonic Sensor
Bread Board
3 Jumper Wires

1. Plug your sensor into the Bread board so there are still open holes behind it
2. Insert 3 different colored jumper wires behind the connecting pins of the Sensor in the Bread Board.
3. Noting which cable corresponds to which sensor insert the correct wire into the Arduino Uno Board
GND to GND
VCC to the correct power (in my case 5V)
SIG to a Digital Pin (I am using Digital Pin 2)

http://www.instructables.com/id/Reading-Ultrasonic-Sensor-Data-to-FireFly/
Step 3: Starting your sketch and Opening a Port
1. Launch Rhino and Grasshopper
2. Start your Firefly sketch by navigating to the Firefly tab in Grasshopper
1. Opening the Port
1. Click on the Port node and bring it into your sketch
2. Create a Panel and connect it to the "Ports Available" node.
This will let you see what ports are available on your machine, and is why you will need to know what port your Arduino Uno is connected to
3. Create a "Value List" node and double click on it
4. Enter the Value's item you see in your Panel
1. In my case I will enter "0" and "1" and click "OK"
2. select the port that your Arduino Uno is on by clicking on the down arrow
5. Insert a "List Item" node
1. Connect your Panel to the L input
2. Connect the Value List to the i input
6. Insert a "Open Port" node into the sketch
1. Connect the "List Item" node to the "Port" input
7. Insert a "Boolean Toggle" to the Sketch
1. Connect it to the "Open" input
8. Create a "Value List" and edit the values to include and connect it to the "Baud" input on the "Open Port" node
2400, 4800, 9600, 14400,19200, 28800, 38400, 57600 and 115200
Select the 115200 value
9. Connect a Panel to the "Msg" output of the "Open Port" node
10. Double Click on the False Button in your Toggle node to turn it to true
11. You should now see your panel coming from the open port reading
"Hooray! The serial port is open and you may now begin reading or writing data to the serial port."

http://www.instructables.com/id/Reading-Ultrasonic-Sensor-Data-to-FireFly/
Image Notes
1. Editing the Value List

Step 4: Reading from the Arduino Board


Now that you have your Port opened the next step is to read the data that the Ultra Sonic Sensor is collecting.

1. Insert a "Uno Read" and another "Boolean Toggle" node into the sketch
1. Connect the newly added "Boolean Toggle" to "Start" input
2. Connect the "List Item" that is calling out what port to the "Port" input
2. Attach Panels to the outputs of the "Uno Read"
1. I like to group my panels for the outputs I'm not using and leave the ones I am as individual
1. Connect APin0 to APin5 to a Panel
2. Connect DPin2 to a Panel
3. Connect DPin4 and DPin7 to a Panel
4. Connect Msg to a Pannel
You will see that these have the value of <null> and the Msg will read "The serial port is open so you may begin reading data by setting the
Start boolean value to True."
Insert and Attach a "Timer" node to the "Uno Read" and set it to the time you want it to run commands
Double Click the Toggle attached to "Uno Read"
If you look in the DPin2 Panel as you move an object closer and further from the Scanner the values will change
The Default unit is Centimeters, you can either modify this in the Firmata or do conversion within Grasshopper

Step 5: Converting to a different Unit


If you don't want to use CM as your base unit you can convert the distance reading either in Firefly or the Firmata. I chose to use Firefly and use an add in called "TT
Tollbox" but you can also do a multiplication function to accomplish this. The reason I am using the TT Toolbox plugin is because it lets you switch quickly between units.

1. Navigate to the TT Toolbox tab and insert a unit converter node into the sketch
1. Connect the output from the Panel attached to DPin2 to the "F" input
2. Create a Value List node and edit the contents to:
MM
CM
M
IN
FT
3. Create a duplicate and attach one to the "Target Unit" (TU) input and change it to the unit that you want to display, and the other to the "Source Unit" (SU)
Input and change it to "cm".
4. Attach a Panel to the "Value" output to see the converted number

http://www.instructables.com/id/Reading-Ultrasonic-Sensor-Data-to-FireFly/
Related Instructables

Arduino Kirlian
How to add
Ultrasonic Ping Solidifying Sand Sand inspection device by Denise
Page Navigation
with Arduino by chris.kelusak Solidification Menu without vehicle by Flasz
(Basic) by Box Creation v1 Using Open 100whitetiger001
chris.kelusak by chris.kelusak Hook Plugin in
Thesis Theme
(video) by
mathanraj

Advertisements

Comments

http://www.instructables.com/id/Reading-Ultrasonic-Sensor-Data-to-FireFly/

You might also like