0% found this document useful (0 votes)
50 views50 pages

Connecting Hardware To Flex

This document provides an overview of connecting Arduino open source hardware to Flex applications. It discusses trends in electronics, computing, and communication that enable these connections. The Arduino platform is introduced, including its hardware, boards, shields, and software. Methods for connecting Flex to Arduino via an ActionScript library and USB are described. Examples demonstrate controlling Arduino digital outputs and reading analog inputs from Flex. Wireless communication using XBee modems is also covered. Useful hardware and software sites for further information are listed.
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)
50 views50 pages

Connecting Hardware To Flex

This document provides an overview of connecting Arduino open source hardware to Flex applications. It discusses trends in electronics, computing, and communication that enable these connections. The Arduino platform is introduced, including its hardware, boards, shields, and software. Methods for connecting Flex to Arduino via an ActionScript library and USB are described. Examples demonstrate controlling Arduino digital outputs and reading analog inputs from Flex. Wireless communication using XBee modems is also covered. Useful hardware and software sites for further information are listed.
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/ 50

Connecting Hardware to

Flex
A practical guide to connecting open source
hardware (Arduino’s) to Flex

Justin Mclean
Class Software
Who am I?
• Director of Class Software for 10 years
• Developing and creating web applications for
15 years
• Programming for 25 years
• Adobe solution partner
• Adobe certified developer and trainer in Flex
and ColdFusion
• Based in Sydney Australia
Electronics Trends
• Low cost small components
• More complex components with simple
standard interfaces
• Cheap low volume board manufacture
Computing Trends
• Easier to program
• Use of high level languages
• Software tools
• Open source
Communication Trends
• Low cost long range wireless
• Mesh networks
Are We There Yet?
• Low cost fast devices
• It’s easy to communicate between devices and
computers
• Can build complex systems from off the shelf
components
• Commercial and open source products and
kits are available
Arduino
Open source hardware and software
platform
Arduino Platform
• Open source hardware and software platform
• Easy to program
• Hardware is flexible, fast, low power and low
cost
Arduino Hardware
• Comes in a number of shapes sizes
• Low cost
• Easy to program
• Easy to extend
Arduino Boards
Arduino Boards
Arduino Boards
Arduino Boards
Arduino Shields
Arduino Shields
Arduino Shields
Arduino Shields
Arduino Software Platform
• Open source cross platform IDE
• Alpha but very stable
• Code in high level C like language
• Updated frequently
• Growing and active community
Arduino IDE
Arduino Code
• C like high level language
• Inbuilt functions to read and set digital and
analog inputs and outputs
• Includes libraries to perform common
hardware or software tasks
Led Shield Demo
Led Shield Demo
Setup and Loop Functions
• Setup function called once
void setup() {
...
}
• Loop function called over and over again
void loop() {
...
}
Setting Digital Outputs
• Set digital pin as output in setup
pinMode(pin, OUTPUT);
• Digital outputs turned on or off in setup or
loop

digitalWrite(pin, HIGH);

digitalWrite(pin, LOW);
Flex
Flex to Arduino communication
Layers of Communication
• Flex to proxy via an Actionscript library
• Proxy to USB communication
• USB to arduino
Computer Arduino

Flex Code Arduino

Function Calls and


Code
Events

TCP/IP USB
AS3 Glue USB Proxy Firmata
Socket Cable

Flex to Arduino
Flex Led Demo
AS3Glue Digital Output
• Create arduino instance
var arduino:Arduino = new Arduino();
• Wait for firmware version
• Set digital pin as output
arduino.setPinMode(pin, Arduino.OUTPUT);
• Turn digital output on
arduino.writeDigitalPin(pin, Arduino.HIGH);
AS3Glue Events
• Uses Flex events for digital inputs.
• Listen for changes via event listener
arduino.addEventListener
(ArduinoEvent.DIGITAL_DATA,
onReceiveData);

public function onReceiveData


(event:ArduinoEvent):void {
}
Wireless
Communication
Wireless communication with XBee
modems
XBee Modems
• Hardware wireless modem
• Low cost
• Consume very little power
• Good range
• Easy to configure
XBee Modem
XBee Networks
• Point to point
• Point to multipoint
• Mesh
Funnel IO
• Arduino based hardware
• Java server
• Flex library
Funnel Digital Output
Funnel Digital Output
Funnel Digital Output
Setting Digital Output
• Create FIO instance
var fio:Fio = new Fio([1], Fio.FIRMATA);
• Turn digital output on or off by setting value
fio.ioModule(1).digitalPin(pin).value = 1;
Funnel Analog Graph
Funnel Analog Graph
Reading Analog Input
• Read analog value same way as digital value
value = ioModule(1).analogPin(pin).value;
• Event based
analogPin(pin).addEventListener(
PinEvent.CHANGE, function);
• Timer based
Issues
• Debugging can be hard
• No simulator
• Memory, power and speed limits
• Need a little electronic knowledge
Why do this?
• Expose yourself to new ideas and new ways of
solving problems
• Involves interaction with the real world
• Encourages creativity
• Platform limits improves programming skill
It’s Fun!
Questions?
Ask now, see me after the session or
email me at [email protected]
Useful Sites
List of useful hardware of software
sites
Software Sites
• Arduino http://www.arduino.cc for software,
user forum and playground
• AS3Glue http://code.google.com/p/as3glue/
• Funnel IO http://funnel.cc/
Hardware Sites
• Spark Fun (US) http://www.sparkfun.com/
• Adafruit Industries (US) http://
www.adafruit.com/
• Electronic Goldmine (US) http://
www.goldmine-elec.com/
Other Sites
• Lady Ada http://www.ladyada.net/
• Evil Mad Scientist http://
www.evilmadscientist.com/
• NY Resistor http://www.nycresistor.com/
• Make Zine http://makezine.com/

You might also like