A practical guide to connecting hardware to Flex

50
Connecting Hardware to Flex A practical guide to connecting open source hardware to Flex Justin Mclean Class Software Friday, 22 May 2009
  • date post

    17-Oct-2014
  • Category

    Technology

  • view

    6.333
  • download

    3

description

WebDU 2009 session looking at the revolution in low cost easy to program embedded computing. It focuses on the arduino open source hardware and software platform and zigbee network modules and how both of these can be easily connected up to Adobe Flex.

Transcript of A practical guide to connecting hardware to Flex

Page 1: A practical guide to connecting hardware to Flex

Connecting Hardware to FlexA practical guide to connecting open source hardware to Flex

Justin McleanClass Software

Friday, 22 May 2009

Page 2: A practical guide to connecting hardware to Flex

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

Friday, 22 May 2009

Page 3: A practical guide to connecting hardware to Flex

Electronics Trends• Low cost small components

• More complex components with simple standard interfaces

• Cheap low volume board manufacture

Friday, 22 May 2009

Page 4: A practical guide to connecting hardware to Flex

Computing Trends• Easier to program

• Use of high level languages

• Software tools

• Open source

Friday, 22 May 2009

Page 5: A practical guide to connecting hardware to Flex

Communication Trends• Low cost long range wireless

• Mesh networks

Friday, 22 May 2009

Page 6: A practical guide to connecting hardware to Flex

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

Friday, 22 May 2009

Page 7: A practical guide to connecting hardware to Flex

ArduinoOpen source hardware and software platform

Friday, 22 May 2009

Page 8: A practical guide to connecting hardware to Flex

Arduino Platform• Open source hardware and software platform

• Easy to program

• Hardware is flexible, fast, low power and low cost

Friday, 22 May 2009

Page 9: A practical guide to connecting hardware to Flex

Arduino Hardware• Comes in a number of shapes sizes

• Low cost

• Easy to program

• Easy to extend

Friday, 22 May 2009

Page 10: A practical guide to connecting hardware to Flex

Arduino Boards

Friday, 22 May 2009

Page 11: A practical guide to connecting hardware to Flex

Arduino Boards

Friday, 22 May 2009

Page 12: A practical guide to connecting hardware to Flex

Arduino Boards

Friday, 22 May 2009

Page 13: A practical guide to connecting hardware to Flex

Arduino Boards

Friday, 22 May 2009

Page 14: A practical guide to connecting hardware to Flex

Arduino Shields

Friday, 22 May 2009

Page 15: A practical guide to connecting hardware to Flex

Arduino Shields

Friday, 22 May 2009

Page 16: A practical guide to connecting hardware to Flex

Arduino Shields

Friday, 22 May 2009

Page 17: A practical guide to connecting hardware to Flex

Arduino Shields

Friday, 22 May 2009

Page 18: A practical guide to connecting hardware to Flex

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

Friday, 22 May 2009

Page 19: A practical guide to connecting hardware to Flex

Arduino IDE

Friday, 22 May 2009

Page 20: A practical guide to connecting hardware to Flex

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

Friday, 22 May 2009

Page 21: A practical guide to connecting hardware to Flex

Led Shield Demo

Friday, 22 May 2009

Page 22: A practical guide to connecting hardware to Flex

Led Shield Demo

Friday, 22 May 2009

Page 23: A practical guide to connecting hardware to Flex

Setup and Loop Functions• Setup function called once

void setup() {...}

• Loop function called over and over again

void loop() {...}

Friday, 22 May 2009

Page 24: A practical guide to connecting hardware to Flex

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);

Friday, 22 May 2009

Page 25: A practical guide to connecting hardware to Flex

FlexFlex to Arduino communication

Friday, 22 May 2009

Page 26: A practical guide to connecting hardware to Flex

Layers of Communication• Flex to proxy via an Actionscript library

• Proxy to USB communication

• USB to arduino

Friday, 22 May 2009

Page 27: A practical guide to connecting hardware to Flex

USB Proxy FirmataAS3 Glue

Flex Code Arduino

USBCable

TCP/IPSocket

Computer Arduino

Function Calls and Events

Code

Flex to Arduino

Friday, 22 May 2009

Page 28: A practical guide to connecting hardware to Flex

Flex Led Demo

Friday, 22 May 2009

Page 29: A practical guide to connecting hardware to Flex

AS3Glue Digital Output • Create arduino instance

var arduino:Arduino = new Arduino();

• Set digital pin as output

arduino.setPinMode(pin, Arduino.OUTPUT);

• Turn digital output on

arduino.writeDigitalPin(pin, Arduino.HIGH);

Friday, 22 May 2009

Page 30: A practical guide to connecting hardware to Flex

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 {}

Friday, 22 May 2009

Page 31: A practical guide to connecting hardware to Flex

Wireless CommunicationWireless communication with XBee modems

Friday, 22 May 2009

Page 32: A practical guide to connecting hardware to Flex

XBee Modems• Hardware wireless modem

• Low cost

• Consume very little power

• Good range

• Easy to configure

Friday, 22 May 2009

Page 33: A practical guide to connecting hardware to Flex

XBee Modem

Friday, 22 May 2009

Page 34: A practical guide to connecting hardware to Flex

XBee Networks• Point to point

• Point to multipoint

• Mesh/Peer to peer

Friday, 22 May 2009

Page 35: A practical guide to connecting hardware to Flex

Funnel IO• Arduino based hardware

• Java server

• Flex library

Friday, 22 May 2009

Page 36: A practical guide to connecting hardware to Flex

Funnel Digital Output

Friday, 22 May 2009

Page 37: A practical guide to connecting hardware to Flex

Funnel Digital Output

Friday, 22 May 2009

Page 38: A practical guide to connecting hardware to Flex

Funnel Digital Output

Friday, 22 May 2009

Page 39: A practical guide to connecting hardware to Flex

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;

Friday, 22 May 2009

Page 40: A practical guide to connecting hardware to Flex

Funnel Analog Graph

Friday, 22 May 2009

Page 41: A practical guide to connecting hardware to Flex

Funnel Analog Graph

Friday, 22 May 2009

Page 42: A practical guide to connecting hardware to Flex

Reading Analog Input• Not event based, need to use timer

• Read analog value same way as digital value

value = ioModule(1).analogPin(pin).value;

Friday, 22 May 2009

Page 43: A practical guide to connecting hardware to Flex

Issues• Debugging can be hard

• No simulator

• Memory, power and speed limits

• Need a little electronic knowledge

Friday, 22 May 2009

Page 44: A practical guide to connecting hardware to Flex

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

Friday, 22 May 2009

Page 45: A practical guide to connecting hardware to Flex

It’s Fun!

Friday, 22 May 2009

Page 46: A practical guide to connecting hardware to Flex

Questions?Ask now, see me after the session or email me at [email protected]

Friday, 22 May 2009

Page 47: A practical guide to connecting hardware to Flex

Useful SitesList of useful hardware of software sites

Friday, 22 May 2009

Page 48: A practical guide to connecting hardware to Flex

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/

Friday, 22 May 2009

Page 49: A practical guide to connecting hardware to Flex

Hardware Sites• Little Bird Electronics (Australian) - http://

www.littlebirdelectronics.com/

• Jaycar (Australian) http://jaycar.com.au/

• Adafruit Industries (US) http://www.adafruit.com/

• Spark Fun (US) http://www.sparkfun.com/

• Electronic Goldmine (US) http://www.goldmine-elec.com/

Friday, 22 May 2009

Page 50: A practical guide to connecting hardware to Flex

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/

Friday, 22 May 2009