SlideShare a Scribd company logo
1 of 8
Download to read offline
Getting Started with Firefly
The City University of New York
Architectural Technology Dept.
written by Anthony Gonzalez
GettingStartedwithFirefly
2
Introduction
Firefly is a suite of software tools written for the
Grasshopper plug-in that enable you to drive
parametric values through sensor data via an Arduino
microcontroller. In addition to slaving parameters of a
GrasshopperdefinitiontothatofanArduino-connected
sensor (or creating a mathematical relationship
between a sensor measurement and a controlled
parameter), Firefly also enables parameters to behave
as outputs that drive actuation (eg. motors, LEDS,
etc.). Thus, using Firefly, there is potential for two-way
communication where not only can you determine the
state of external physical conditions and use that data
to construct and/or manipulate responsive virtual
models, you can also use those same virtual models
and their parameters as outputs that control the state
of responsive physical environments.
The Firefly Installation files are available at http://
www.fireflyexperiments.com/download
GettingStartedwithFirefly
3
Preparing for Firefly Communication
Assuming you have already installed the Arduino
IDE and your Arduino board is currently connected
to your workstation, you must now upload the Firefly
Firmata sketch to the Arduino board. Firmata is what
is described as a “generic protocol for communicating
with microcontrollers from software on a host
computer.” In other words, by uploading the Firefly
Firmata sketch you are essentially embedding a
prewritten program onto the Arduino board that allows
Firefly to both read from and write to the Arduino’s pins.
Once uploaded, you can move away from the Arduino
IDE and create all programmatic behavior through the
visual programming language of Grasshopper.
The Firefly Firmata is available at http://www.
fireflyexperiments.com/download
GettingStartedwithFirefly
4
The Firefly Toolbar
Fig. 1 shows the Firefly toolbar as it is in Grasshopper.
As you can see, Firefly actually adds more functionality
to Grasshopper than just Arduino communication.
As seen in Fig. 1, Firefly provides components to
interface with audio input, send & receive data over a
network, and even open up a webcam feed. However,
the components we are concerned about here are
in the panel to the far left (shows in Fig. 2). These
are components specifically related to your Arduino
microcontroller (ignore the Wii object). Depending on
the model of Arduino board you are using, the most
important component to become familiar with is
either the UNO or MEGA component along with its two
variations: READ and WRITE.
Fig. 1 -Firefly Toolbar
Fig. 2 -Firefly Toolbar
GettingStartedwithFirefly
5
The Virtual Arduino
The functionality of the physical Arduino board
(specific pins behaving as either INPUTS or OUTPUTS)
is virtually represented within Firefly as two separate
components (as shown in Fig. 3 & Fig. 4).
Through this simple binary implementation, Firefly
has already designated which pins on the Arduino
board can behave as INPUTS (those assigned to
the ‘Read’ component) and those pins which can
behave as OUTPUTS (those assigned to the ‘Write’
component). While this limits a certain amount of
flexibility in choosing which pins behave in which
manner (like when coding in the Arduino IDE), with
this “hard-coded” approach conflict is averted and the
extra step of assigning behavior to the specific pins
you plan to use is eliminated. Notice in the ‘Read’
object, all six analog pins are available to read, which
makes perfect sense since analog pins are meant
for sensing (measuring voltage) and even in the
Arduino IDE voltage values other than HIGH or LOW
cannot actually be written to analog pins. In addition
to interfacing with analog pins, the ‘Read’ component
interfaces with three digital pins: DPin2, DPin4, and
DPin7. Now look at the ‘Write” component and notice
the absence of analog pins (perfectly legitimate)
and the inclusion of nine digital pins: DPin3, DPin5,
DPin6, DPin8, DPin9, DPin10, DPin11, DPin12, and
DPin13. Digital pins 2, 4, 7 are excluded from the
‘Write’ component because they have already been
designated by Firefly as INPUTS (by their inclusion in
the ‘Read’ component). When wiring, make sure to
note that digital pins 0 and 1 are reserved for serial
communication and are not represented in either the
‘Read’ or ‘Write’ components.
Fig. 3 -Uno Read Component Fig. 4 -Uno Write Component
GettingStartedwithFirefly
6
Reading & Writing to Pins
While the ‘Read’ and “Write’ components are
critical to interfacing with the Arduino board, in
turn, these components depend on other smaller
components in order to operate properly. Before any
kind of communication can take place between the
Arduino board and Grasshopper (or any other piece
of software) a serial port must be opened for that
communication to take place.
The ‘Open Port’ component (shown in Fig. 5)
establishes and opens a port over which
communication will take place between the Arduino
board and Grasshopper. This component requires
three input parameters: Open, Port, and Baud. Open
accepts a “Boolean” value (True or False) which is
easiest to interface with using the “Boolean Toggle”
parameter (under Params > Special) while Port and
Baud accept “Integer” parameters (under Params >
Primitive). The significance of each parameter is self
explanatory: the “Boolean” opens and closes the
connection respectively, the Port “Integer” tells the
component which communication port the Arduino
board is actually connected to, and the Baud “Integer”
tells the port at what transmission speed to operate
(this rate must match the rate defined in the Firefly
Firmata sketch which by default is 115200). The
number assigned to the communication port used by
your Arduino board can be determined in two different
ways: using the Device Manager or through Firefly’s
“Ports Available” component (shown in Fig. 6).
Fig. 5 -Open Port Component Fig. 6 -Ports Available Component
GettingStartedwithFirefly
7
Reading & Writing
Uno Read
Once you have determined the correct port number,
have entered that number into the “Integer”
parameter connected to the “Open Port” component,
and have set the Open property of that component
to True, you are now ready to begin communicating
with the Arduino board. Let’s look at the “Uno Read”
component again (shown in Fig. 7).
Although you have already established and opened a
port over which communication between the Arduino
board and Grasshopper can take place, both the
“Uno Read” and “Uno Write” components require a
clear directive to actually begin utilizing that open
port. This directive is defined through two required
input parameters: Start and Port. The Start input
expects a “Boolean” value and the Port input expects
an “Integer” value (naturally, the corresponding port
number of the line of communication you have already
opened in the “Open Port” component). In addition to
initializing the “Uno Read” component, you must also
define how often to check for updated values from the
Arduino board. This is accomplished by connecting a
“Timer” object directly to the “Uno Read” component.
The “Timer” object sends pulses at a set interval (in
this case every 20ms) to the “Uno Read” component,
which essentially command the component to retrieve
new values for each of the Arduino board’s input pins.
Now let’s set our “Boolean Toggle” to True and connect
some text panels to our component outputs for some
feedback and… you’re now reading values from our
Arduino board’s input pins (as shown in Fig. 8).
Fig. 7 -Uno Read Component Fig. 8 -Uno Read Component
GettingStartedwithFirefly
8
Reading & Writing
Uno write
Using the “Uno Read” component you’ve now used
Firefly as an input to retrieve data from the Arduino
board’s output pins. With this data, you can drive
any parameter of your Grasshopper definition in any
manner that you desire. The counterpart to “Uno
Read” is the “Uno Write” component (shown in Fig. 9)
which allows you to use Firefly as an output that can
send data to the Arduino board’s input pins.
If you remember how to initialize and begin sending
pulses to the “Uno Read” component, then you’ll have
no trouble getting the “Uno Write” component up and
running. Notice the two input parameters Start and
Port as well as the “Timer” object connected directly
to the “Uno Write” component. The obvious difference
here is the number of inputs available, which
correspond to the pins you can control on the Arduino
board from Grasshopper. Each digital pin input
parameter (eg. DPin13) expects either a “Boolean”
or “Integer” value. As in most if not all programming
languages, True evaluates to 1, False evaluates to
0, and vice versa. In addition, any non-zero integer
evaluates to True.
Taking a closer look at the input parameters of “Uno
Write” you’ll notice a small variation on specific digital
pins, specifically the tilde (~). The tilde defines pins
that can be used for either digital input (0 or 1 / false
or true) or PWM (pulse width modulation). In brief,
PWM uses square waves to simulate analog values
by modulating the time the signal is high by the time
the signal is low. These pins can accept integers other
than 0 or 1 and are great for fading LED’s, controlling
motors, etc. By right-clicking the input parameters you
can set how each digital pin should behave (shown in
Fig. 10).
The Out output parameter is included here in order
to demonstrate that the “Uno Write” component
continually writes data to all of the Arduino board’s
input pins regardless of whether you are actually
changing one or all of the “Uno Write” input
parameters.
Fig. 9 -Uno Write Component
Fig. 10 -Set Pin to PWM

More Related Content

What's hot

Intro to Arduino Revision #2
Intro to Arduino Revision #2Intro to Arduino Revision #2
Intro to Arduino Revision #2Qtechknow
 
Arduino Foundations
Arduino FoundationsArduino Foundations
Arduino FoundationsJohn Breslin
 
Arduino Workshop Day 2 - Advance Arduino & DIY
Arduino Workshop Day 2 - Advance Arduino & DIYArduino Workshop Day 2 - Advance Arduino & DIY
Arduino Workshop Day 2 - Advance Arduino & DIYVishnu
 
IRJET- Smart Gloves to Convert Sign Languages to Vocal Output
IRJET- Smart Gloves to Convert Sign Languages to Vocal OutputIRJET- Smart Gloves to Convert Sign Languages to Vocal Output
IRJET- Smart Gloves to Convert Sign Languages to Vocal OutputIRJET Journal
 
Arduino Workshop Day 1 - Basic Arduino
Arduino Workshop Day 1 - Basic ArduinoArduino Workshop Day 1 - Basic Arduino
Arduino Workshop Day 1 - Basic ArduinoVishnu
 
Programming with arduino
Programming with arduinoProgramming with arduino
Programming with arduinoMakers of India
 
Physical prototyping lab1-input_output (2)
Physical prototyping lab1-input_output (2)Physical prototyping lab1-input_output (2)
Physical prototyping lab1-input_output (2)Tony Olsson.
 
C++ Pointers And References
C++ Pointers And ReferencesC++ Pointers And References
C++ Pointers And Referencesverisan
 
아두이노 Digital/Analog IO
아두이노 Digital/Analog IO아두이노 Digital/Analog IO
아두이노 Digital/Analog IOJungHoon Lee
 
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauriArduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauriGaurav Pandey
 
Keyboard interrupt
Keyboard interruptKeyboard interrupt
Keyboard interruptTech_MX
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshopatuline
 
Lily pad dev_handout
Lily pad dev_handoutLily pad dev_handout
Lily pad dev_handoutKhuê Phạm
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming LanguageDipankar Achinta
 

What's hot (20)

Intro to Arduino Revision #2
Intro to Arduino Revision #2Intro to Arduino Revision #2
Intro to Arduino Revision #2
 
Ardx experimenters-guide-web
Ardx experimenters-guide-webArdx experimenters-guide-web
Ardx experimenters-guide-web
 
Arduino Foundations
Arduino FoundationsArduino Foundations
Arduino Foundations
 
Arduino Workshop Day 2 - Advance Arduino & DIY
Arduino Workshop Day 2 - Advance Arduino & DIYArduino Workshop Day 2 - Advance Arduino & DIY
Arduino Workshop Day 2 - Advance Arduino & DIY
 
IRJET- Smart Gloves to Convert Sign Languages to Vocal Output
IRJET- Smart Gloves to Convert Sign Languages to Vocal OutputIRJET- Smart Gloves to Convert Sign Languages to Vocal Output
IRJET- Smart Gloves to Convert Sign Languages to Vocal Output
 
Arduino Workshop Day 1 - Basic Arduino
Arduino Workshop Day 1 - Basic ArduinoArduino Workshop Day 1 - Basic Arduino
Arduino Workshop Day 1 - Basic Arduino
 
Programming with arduino
Programming with arduinoProgramming with arduino
Programming with arduino
 
Physical prototyping lab1-input_output (2)
Physical prototyping lab1-input_output (2)Physical prototyping lab1-input_output (2)
Physical prototyping lab1-input_output (2)
 
Arduino course
Arduino courseArduino course
Arduino course
 
C++ Pointers And References
C++ Pointers And ReferencesC++ Pointers And References
C++ Pointers And References
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
아두이노 Digital/Analog IO
아두이노 Digital/Analog IO아두이노 Digital/Analog IO
아두이노 Digital/Analog IO
 
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauriArduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
 
Pointer in c++ part1
Pointer in c++ part1Pointer in c++ part1
Pointer in c++ part1
 
Keyboard interrupt
Keyboard interruptKeyboard interrupt
Keyboard interrupt
 
Interfacing to
Interfacing toInterfacing to
Interfacing to
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshop
 
Lily pad dev_handout
Lily pad dev_handoutLily pad dev_handout
Lily pad dev_handout
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
 
Pointers
PointersPointers
Pointers
 

Similar to Getting Started with Firefly Communication

Electronz_Chapter_14.pptx
Electronz_Chapter_14.pptxElectronz_Chapter_14.pptx
Electronz_Chapter_14.pptxMokete5
 
Ch_2_8,9,10.pptx
Ch_2_8,9,10.pptxCh_2_8,9,10.pptx
Ch_2_8,9,10.pptxyosikit826
 
Arduino and Circuits.docx
Arduino and Circuits.docxArduino and Circuits.docx
Arduino and Circuits.docxAjay578679
 
Arduino electronics cookbook
Arduino electronics cookbookArduino electronics cookbook
Arduino electronics cookbookFelipe Belarmino
 
Introduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptIntroduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptansariparveen06
 
Digital home automation with arduino bluetooth
Digital home automation with arduino bluetoothDigital home automation with arduino bluetooth
Digital home automation with arduino bluetoothShishupal03012015
 
After COMPUTING THIS IS FOR COMPUTER SCIENTISTS.pptx
After COMPUTING THIS IS FOR COMPUTER SCIENTISTS.pptxAfter COMPUTING THIS IS FOR COMPUTER SCIENTISTS.pptx
After COMPUTING THIS IS FOR COMPUTER SCIENTISTS.pptxElisée Ndjabu
 
Arduino comic v0004
Arduino comic v0004Arduino comic v0004
Arduino comic v0004DO!MAKERS
 
Ardublock tutorial
Ardublock tutorialArdublock tutorial
Ardublock tutorialJakie_Li
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Getting Started With Arduino_Tutorial
Getting Started With Arduino_TutorialGetting Started With Arduino_Tutorial
Getting Started With Arduino_TutorialNYCCTfab
 
Getting startedwitharduino ch04
Getting startedwitharduino ch04Getting startedwitharduino ch04
Getting startedwitharduino ch04Anil Yadav
 

Similar to Getting Started with Firefly Communication (20)

Electronz_Chapter_14.pptx
Electronz_Chapter_14.pptxElectronz_Chapter_14.pptx
Electronz_Chapter_14.pptx
 
Arduino day 2019
Arduino day 2019Arduino day 2019
Arduino day 2019
 
arduino uno
arduino unoarduino uno
arduino uno
 
Arduino: Arduino starter kit
Arduino: Arduino starter kitArduino: Arduino starter kit
Arduino: Arduino starter kit
 
arduino uno.pptx
arduino uno.pptxarduino uno.pptx
arduino uno.pptx
 
Ch_2_8,9,10.pptx
Ch_2_8,9,10.pptxCh_2_8,9,10.pptx
Ch_2_8,9,10.pptx
 
Arduino and Circuits.docx
Arduino and Circuits.docxArduino and Circuits.docx
Arduino and Circuits.docx
 
Arduino electronics cookbook
Arduino electronics cookbookArduino electronics cookbook
Arduino electronics cookbook
 
Introduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptIntroduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).ppt
 
Fun with arduino
Fun with arduinoFun with arduino
Fun with arduino
 
Digital home automation with arduino bluetooth
Digital home automation with arduino bluetoothDigital home automation with arduino bluetooth
Digital home automation with arduino bluetooth
 
After COMPUTING THIS IS FOR COMPUTER SCIENTISTS.pptx
After COMPUTING THIS IS FOR COMPUTER SCIENTISTS.pptxAfter COMPUTING THIS IS FOR COMPUTER SCIENTISTS.pptx
After COMPUTING THIS IS FOR COMPUTER SCIENTISTS.pptx
 
Arduino Comic-Jody Culkin-2011
Arduino Comic-Jody Culkin-2011Arduino Comic-Jody Culkin-2011
Arduino Comic-Jody Culkin-2011
 
Arduino comic v0004
Arduino comic v0004Arduino comic v0004
Arduino comic v0004
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Arduino workshop sensors
Arduino workshop sensorsArduino workshop sensors
Arduino workshop sensors
 
Ardublock tutorial
Ardublock tutorialArdublock tutorial
Ardublock tutorial
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Getting Started With Arduino_Tutorial
Getting Started With Arduino_TutorialGetting Started With Arduino_Tutorial
Getting Started With Arduino_Tutorial
 
Getting startedwitharduino ch04
Getting startedwitharduino ch04Getting startedwitharduino ch04
Getting startedwitharduino ch04
 

More from NYCCTfab

Fusion 360 Tutorial
Fusion 360 TutorialFusion 360 Tutorial
Fusion 360 TutorialNYCCTfab
 
Citytech HTML/CSS Guide
Citytech HTML/CSS GuideCitytech HTML/CSS Guide
Citytech HTML/CSS GuideNYCCTfab
 
Ultimaker 2+
Ultimaker 2+Ultimaker 2+
Ultimaker 2+NYCCTfab
 
Robot Studio
Robot StudioRobot Studio
Robot StudioNYCCTfab
 
Roland Primer 3D Scanner
Roland Primer 3D ScannerRoland Primer 3D Scanner
Roland Primer 3D ScannerNYCCTfab
 
Lighting with Photoshop
Lighting with PhotoshopLighting with Photoshop
Lighting with PhotoshopNYCCTfab
 
Fusion 360 Tutorial
Fusion 360 TutorialFusion 360 Tutorial
Fusion 360 TutorialNYCCTfab
 
Architectural diagrams
Architectural diagramsArchitectural diagrams
Architectural diagramsNYCCTfab
 
Advanced Techniques in Photoshop
Advanced Techniques in PhotoshopAdvanced Techniques in Photoshop
Advanced Techniques in PhotoshopNYCCTfab
 
Adobe Premiere Pro
Adobe Premiere ProAdobe Premiere Pro
Adobe Premiere ProNYCCTfab
 
VRay Lighting for Rhino
VRay Lighting for RhinoVRay Lighting for Rhino
VRay Lighting for RhinoNYCCTfab
 
Adobe Illustrator CC 2018
Adobe Illustrator CC 2018 Adobe Illustrator CC 2018
Adobe Illustrator CC 2018 NYCCTfab
 
Silicone Mold Primer
Silicone Mold PrimerSilicone Mold Primer
Silicone Mold PrimerNYCCTfab
 
Presentation Board Layout
Presentation Board Layout Presentation Board Layout
Presentation Board Layout NYCCTfab
 
CPD Dental Cam Primer
CPD Dental Cam PrimerCPD Dental Cam Primer
CPD Dental Cam PrimerNYCCTfab
 
Temperature and Light Logger (UA-002-64)
Temperature and Light Logger (UA-002-64)Temperature and Light Logger (UA-002-64)
Temperature and Light Logger (UA-002-64)NYCCTfab
 
Telaire CO2 Sensor (Tel-7001)
Telaire CO2 Sensor (Tel-7001)Telaire CO2 Sensor (Tel-7001)
Telaire CO2 Sensor (Tel-7001)NYCCTfab
 
UX90-002 Light & Occupancy Logger
UX90-002 Light & Occupancy LoggerUX90-002 Light & Occupancy Logger
UX90-002 Light & Occupancy LoggerNYCCTfab
 
Light Meter (LM-120)
Light Meter (LM-120)Light Meter (LM-120)
Light Meter (LM-120)NYCCTfab
 
Temperature and Relative Humidity Ext
Temperature and Relative Humidity ExtTemperature and Relative Humidity Ext
Temperature and Relative Humidity ExtNYCCTfab
 

More from NYCCTfab (20)

Fusion 360 Tutorial
Fusion 360 TutorialFusion 360 Tutorial
Fusion 360 Tutorial
 
Citytech HTML/CSS Guide
Citytech HTML/CSS GuideCitytech HTML/CSS Guide
Citytech HTML/CSS Guide
 
Ultimaker 2+
Ultimaker 2+Ultimaker 2+
Ultimaker 2+
 
Robot Studio
Robot StudioRobot Studio
Robot Studio
 
Roland Primer 3D Scanner
Roland Primer 3D ScannerRoland Primer 3D Scanner
Roland Primer 3D Scanner
 
Lighting with Photoshop
Lighting with PhotoshopLighting with Photoshop
Lighting with Photoshop
 
Fusion 360 Tutorial
Fusion 360 TutorialFusion 360 Tutorial
Fusion 360 Tutorial
 
Architectural diagrams
Architectural diagramsArchitectural diagrams
Architectural diagrams
 
Advanced Techniques in Photoshop
Advanced Techniques in PhotoshopAdvanced Techniques in Photoshop
Advanced Techniques in Photoshop
 
Adobe Premiere Pro
Adobe Premiere ProAdobe Premiere Pro
Adobe Premiere Pro
 
VRay Lighting for Rhino
VRay Lighting for RhinoVRay Lighting for Rhino
VRay Lighting for Rhino
 
Adobe Illustrator CC 2018
Adobe Illustrator CC 2018 Adobe Illustrator CC 2018
Adobe Illustrator CC 2018
 
Silicone Mold Primer
Silicone Mold PrimerSilicone Mold Primer
Silicone Mold Primer
 
Presentation Board Layout
Presentation Board Layout Presentation Board Layout
Presentation Board Layout
 
CPD Dental Cam Primer
CPD Dental Cam PrimerCPD Dental Cam Primer
CPD Dental Cam Primer
 
Temperature and Light Logger (UA-002-64)
Temperature and Light Logger (UA-002-64)Temperature and Light Logger (UA-002-64)
Temperature and Light Logger (UA-002-64)
 
Telaire CO2 Sensor (Tel-7001)
Telaire CO2 Sensor (Tel-7001)Telaire CO2 Sensor (Tel-7001)
Telaire CO2 Sensor (Tel-7001)
 
UX90-002 Light & Occupancy Logger
UX90-002 Light & Occupancy LoggerUX90-002 Light & Occupancy Logger
UX90-002 Light & Occupancy Logger
 
Light Meter (LM-120)
Light Meter (LM-120)Light Meter (LM-120)
Light Meter (LM-120)
 
Temperature and Relative Humidity Ext
Temperature and Relative Humidity ExtTemperature and Relative Humidity Ext
Temperature and Relative Humidity Ext
 

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Recently uploaded (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 

Getting Started with Firefly Communication

  • 1. Getting Started with Firefly The City University of New York Architectural Technology Dept. written by Anthony Gonzalez
  • 2. GettingStartedwithFirefly 2 Introduction Firefly is a suite of software tools written for the Grasshopper plug-in that enable you to drive parametric values through sensor data via an Arduino microcontroller. In addition to slaving parameters of a GrasshopperdefinitiontothatofanArduino-connected sensor (or creating a mathematical relationship between a sensor measurement and a controlled parameter), Firefly also enables parameters to behave as outputs that drive actuation (eg. motors, LEDS, etc.). Thus, using Firefly, there is potential for two-way communication where not only can you determine the state of external physical conditions and use that data to construct and/or manipulate responsive virtual models, you can also use those same virtual models and their parameters as outputs that control the state of responsive physical environments. The Firefly Installation files are available at http:// www.fireflyexperiments.com/download
  • 3. GettingStartedwithFirefly 3 Preparing for Firefly Communication Assuming you have already installed the Arduino IDE and your Arduino board is currently connected to your workstation, you must now upload the Firefly Firmata sketch to the Arduino board. Firmata is what is described as a “generic protocol for communicating with microcontrollers from software on a host computer.” In other words, by uploading the Firefly Firmata sketch you are essentially embedding a prewritten program onto the Arduino board that allows Firefly to both read from and write to the Arduino’s pins. Once uploaded, you can move away from the Arduino IDE and create all programmatic behavior through the visual programming language of Grasshopper. The Firefly Firmata is available at http://www. fireflyexperiments.com/download
  • 4. GettingStartedwithFirefly 4 The Firefly Toolbar Fig. 1 shows the Firefly toolbar as it is in Grasshopper. As you can see, Firefly actually adds more functionality to Grasshopper than just Arduino communication. As seen in Fig. 1, Firefly provides components to interface with audio input, send & receive data over a network, and even open up a webcam feed. However, the components we are concerned about here are in the panel to the far left (shows in Fig. 2). These are components specifically related to your Arduino microcontroller (ignore the Wii object). Depending on the model of Arduino board you are using, the most important component to become familiar with is either the UNO or MEGA component along with its two variations: READ and WRITE. Fig. 1 -Firefly Toolbar Fig. 2 -Firefly Toolbar
  • 5. GettingStartedwithFirefly 5 The Virtual Arduino The functionality of the physical Arduino board (specific pins behaving as either INPUTS or OUTPUTS) is virtually represented within Firefly as two separate components (as shown in Fig. 3 & Fig. 4). Through this simple binary implementation, Firefly has already designated which pins on the Arduino board can behave as INPUTS (those assigned to the ‘Read’ component) and those pins which can behave as OUTPUTS (those assigned to the ‘Write’ component). While this limits a certain amount of flexibility in choosing which pins behave in which manner (like when coding in the Arduino IDE), with this “hard-coded” approach conflict is averted and the extra step of assigning behavior to the specific pins you plan to use is eliminated. Notice in the ‘Read’ object, all six analog pins are available to read, which makes perfect sense since analog pins are meant for sensing (measuring voltage) and even in the Arduino IDE voltage values other than HIGH or LOW cannot actually be written to analog pins. In addition to interfacing with analog pins, the ‘Read’ component interfaces with three digital pins: DPin2, DPin4, and DPin7. Now look at the ‘Write” component and notice the absence of analog pins (perfectly legitimate) and the inclusion of nine digital pins: DPin3, DPin5, DPin6, DPin8, DPin9, DPin10, DPin11, DPin12, and DPin13. Digital pins 2, 4, 7 are excluded from the ‘Write’ component because they have already been designated by Firefly as INPUTS (by their inclusion in the ‘Read’ component). When wiring, make sure to note that digital pins 0 and 1 are reserved for serial communication and are not represented in either the ‘Read’ or ‘Write’ components. Fig. 3 -Uno Read Component Fig. 4 -Uno Write Component
  • 6. GettingStartedwithFirefly 6 Reading & Writing to Pins While the ‘Read’ and “Write’ components are critical to interfacing with the Arduino board, in turn, these components depend on other smaller components in order to operate properly. Before any kind of communication can take place between the Arduino board and Grasshopper (or any other piece of software) a serial port must be opened for that communication to take place. The ‘Open Port’ component (shown in Fig. 5) establishes and opens a port over which communication will take place between the Arduino board and Grasshopper. This component requires three input parameters: Open, Port, and Baud. Open accepts a “Boolean” value (True or False) which is easiest to interface with using the “Boolean Toggle” parameter (under Params > Special) while Port and Baud accept “Integer” parameters (under Params > Primitive). The significance of each parameter is self explanatory: the “Boolean” opens and closes the connection respectively, the Port “Integer” tells the component which communication port the Arduino board is actually connected to, and the Baud “Integer” tells the port at what transmission speed to operate (this rate must match the rate defined in the Firefly Firmata sketch which by default is 115200). The number assigned to the communication port used by your Arduino board can be determined in two different ways: using the Device Manager or through Firefly’s “Ports Available” component (shown in Fig. 6). Fig. 5 -Open Port Component Fig. 6 -Ports Available Component
  • 7. GettingStartedwithFirefly 7 Reading & Writing Uno Read Once you have determined the correct port number, have entered that number into the “Integer” parameter connected to the “Open Port” component, and have set the Open property of that component to True, you are now ready to begin communicating with the Arduino board. Let’s look at the “Uno Read” component again (shown in Fig. 7). Although you have already established and opened a port over which communication between the Arduino board and Grasshopper can take place, both the “Uno Read” and “Uno Write” components require a clear directive to actually begin utilizing that open port. This directive is defined through two required input parameters: Start and Port. The Start input expects a “Boolean” value and the Port input expects an “Integer” value (naturally, the corresponding port number of the line of communication you have already opened in the “Open Port” component). In addition to initializing the “Uno Read” component, you must also define how often to check for updated values from the Arduino board. This is accomplished by connecting a “Timer” object directly to the “Uno Read” component. The “Timer” object sends pulses at a set interval (in this case every 20ms) to the “Uno Read” component, which essentially command the component to retrieve new values for each of the Arduino board’s input pins. Now let’s set our “Boolean Toggle” to True and connect some text panels to our component outputs for some feedback and… you’re now reading values from our Arduino board’s input pins (as shown in Fig. 8). Fig. 7 -Uno Read Component Fig. 8 -Uno Read Component
  • 8. GettingStartedwithFirefly 8 Reading & Writing Uno write Using the “Uno Read” component you’ve now used Firefly as an input to retrieve data from the Arduino board’s output pins. With this data, you can drive any parameter of your Grasshopper definition in any manner that you desire. The counterpart to “Uno Read” is the “Uno Write” component (shown in Fig. 9) which allows you to use Firefly as an output that can send data to the Arduino board’s input pins. If you remember how to initialize and begin sending pulses to the “Uno Read” component, then you’ll have no trouble getting the “Uno Write” component up and running. Notice the two input parameters Start and Port as well as the “Timer” object connected directly to the “Uno Write” component. The obvious difference here is the number of inputs available, which correspond to the pins you can control on the Arduino board from Grasshopper. Each digital pin input parameter (eg. DPin13) expects either a “Boolean” or “Integer” value. As in most if not all programming languages, True evaluates to 1, False evaluates to 0, and vice versa. In addition, any non-zero integer evaluates to True. Taking a closer look at the input parameters of “Uno Write” you’ll notice a small variation on specific digital pins, specifically the tilde (~). The tilde defines pins that can be used for either digital input (0 or 1 / false or true) or PWM (pulse width modulation). In brief, PWM uses square waves to simulate analog values by modulating the time the signal is high by the time the signal is low. These pins can accept integers other than 0 or 1 and are great for fading LED’s, controlling motors, etc. By right-clicking the input parameters you can set how each digital pin should behave (shown in Fig. 10). The Out output parameter is included here in order to demonstrate that the “Uno Write” component continually writes data to all of the Arduino board’s input pins regardless of whether you are actually changing one or all of the “Uno Write” input parameters. Fig. 9 -Uno Write Component Fig. 10 -Set Pin to PWM