Top Banner
A PRACTICAL GUIDE TO CONNECTING HARDWARE TO FLEX Justin Mclean Class Software Email: [email protected] Twitter: @justinmclean Blog: http://blog.classsoftware.com Tuesday, 21 June 2011
52

A Practical Guide to Connecting Hardware to Flex

Jan 28, 2015

Download

Technology

Justin Mclean

A look at the revolution in low cost, easy to program embedded computing and how to connect it to Flex. Focusing on the Arduino open source hardware and software platform and how it can be easily connected both directly and via the Ethernet. The slides cover digital and analogue input and output and how to create your own web server (in under 20 lines of code). It’s easier than you realise to interface Flex with hardware and with a little knowledge you too can can do this.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: A Practical Guide to Connecting Hardware to Flex

A PRACTICAL GUIDE TO CONNECTING HARDWARE TO FLEXJustin McleanClass Software

Email: [email protected]: @justinmcleanBlog: http://blog.classsoftware.com

Tuesday, 21 June 2011

Page 2: A Practical Guide to Connecting Hardware to Flex

Who am I?• Director of Class Software for almost 15 years

• Developing and creating web applications for 15 years

• Programming for 25 years

• Adobe certified developer and trainer in Flex and ColdFusion

• Adobe Community Champion

• Based in Sydney Australia

Tuesday, 21 June 2011

Page 3: A Practical Guide to Connecting Hardware to Flex

Electronics Trends• Low cost components

• Small components

• Complex components with simple standard interfaces

Tuesday, 21 June 2011

Page 4: A Practical Guide to Connecting Hardware to Flex

Computing Trends• Easier to program

• Use of high level languages

• Software tools

• Open source

Tuesday, 21 June 2011

Page 5: 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

Tuesday, 21 June 2011

Page 6: A Practical Guide to Connecting Hardware to Flex

ArduinoOverview of the Arduino Platform

Tuesday, 21 June 2011

Page 7: A Practical Guide to Connecting Hardware to Flex

Arduino Platform• Open source hardware and software platform

• Easy to program

• Hardware is flexible, fast, consumes very little power and is cheap

Tuesday, 21 June 2011

Page 8: A Practical Guide to Connecting Hardware to Flex

Arduino Hardware• Comes in a number of shapes and sizes

• Low cost

• Easy to extend

• Digital inputs/outputs

• Analog inputs

Tuesday, 21 June 2011

Page 9: A Practical Guide to Connecting Hardware to Flex

Arduino Boards

Tuesday, 21 June 2011

Page 10: A Practical Guide to Connecting Hardware to Flex

Arduino Boards

Tuesday, 21 June 2011

Page 11: A Practical Guide to Connecting Hardware to Flex

Arduino Boards

Tuesday, 21 June 2011

Page 12: A Practical Guide to Connecting Hardware to Flex

Arduino Boards

Tuesday, 21 June 2011

Page 13: A Practical Guide to Connecting Hardware to Flex

Arduino Shields

Tuesday, 21 June 2011

Page 14: A Practical Guide to Connecting Hardware to Flex

Arduino Shields

Tuesday, 21 June 2011

Page 15: A Practical Guide to Connecting Hardware to Flex

Arduino Shields

Tuesday, 21 June 2011

Page 16: A Practical Guide to Connecting Hardware to Flex

Arduino Shields

Tuesday, 21 June 2011

Page 17: A Practical Guide to Connecting Hardware to Flex

Arduino Software Platform• Open source cross platform IDE

• Alpha but very stable

• Version 1.0 out in the next month

• Updated frequently

• Growing and active community

Tuesday, 21 June 2011

Page 18: A Practical Guide to Connecting Hardware to Flex

Arduino Code• C/C++ but not scary!

• Inbuilt functions to read and set digital and analog inputs and outputs

• Includes libraries to perform common hardware or software tasks

• Once uploaded programs are permanent

Tuesday, 21 June 2011

Page 19: A Practical Guide to Connecting Hardware to Flex

Arduino IDE

Tuesday, 21 June 2011

Page 20: A Practical Guide to Connecting Hardware to Flex

Led Shield Demo

Tuesday, 21 June 2011

Page 21: A Practical Guide to Connecting Hardware to Flex

Led Shield Demo

Tuesday, 21 June 2011

Page 22: A Practical Guide to Connecting Hardware to Flex

Issues• Debugging can be hard

• No simulator

• Memory, power and speed limits

• Helps to have a little electronics knowledge

Tuesday, 21 June 2011

Page 23: A Practical Guide to Connecting Hardware to Flex

Connectingto the WebHow Arduinos can communicate with the world

Tuesday, 21 June 2011

Page 24: A Practical Guide to Connecting Hardware to Flex

Connection Methods• Direct to computer (USB)

• Wireless (XBee modems)

• Ethernet or WiFi

• “The Cloud”

Tuesday, 21 June 2011

Page 25: A Practical Guide to Connecting Hardware to Flex

Supported Languages• Flash and Flex

• Processing

• Python

• Ruby

• Java

• C, C++, C# and Objective C

• .NET

Tuesday, 21 June 2011

Page 26: A Practical Guide to Connecting Hardware to Flex

FlexFlex to Arduino direct connection

Tuesday, 21 June 2011

Page 27: 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

Tuesday, 21 June 2011

Page 28: 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

Tuesday, 21 June 2011

Page 29: A Practical Guide to Connecting Hardware to Flex

Flex Led Demo

Tuesday, 21 June 2011

Page 30: A Practical Guide to Connecting Hardware to Flex

AS3Glue Digital Output • Create arduino instance

var arduino:Arduino = new Arduino();

• Wait for firmware version

• Set digital pin as outputarduino.setPinMode(pin, Arduino.OUTPUT);

• Turn digital output onarduino.writeDigitalPin(pin, Arduino.HIGH);

Tuesday, 21 June 2011

Page 31: A Practical Guide to Connecting Hardware to Flex

Danger Shield Demo

Tuesday, 21 June 2011

Page 32: A Practical Guide to Connecting Hardware to Flex

AS3Glue Analog Input• Turn on analog reporting

arduino.setAnalogPinReporting(pin, Arduino.ON);

• Listen for changes via event listenerarduino.addEventListener(ArduinoEvent.ANALOG_DATA, onReceiveData);

public function onReceiveData(event:ArduinoEvent):void { ... }

Tuesday, 21 June 2011

Page 33: A Practical Guide to Connecting Hardware to Flex

EthernetUsing Arduino Ethernet Shields

Tuesday, 21 June 2011

Page 34: A Practical Guide to Connecting Hardware to Flex

Ethernet Shields• Allow direct internet connection

• No dedicated PC needed

• Shields need a little config

• Can act as web server or client

Tuesday, 21 June 2011

Page 35: A Practical Guide to Connecting Hardware to Flex

Ethernet Shields

Tuesday, 21 June 2011

Page 36: A Practical Guide to Connecting Hardware to Flex

Ethernet Shields

Tuesday, 21 June 2011

Page 37: A Practical Guide to Connecting Hardware to Flex

Ethernet Shields

Tuesday, 21 June 2011

Page 38: A Practical Guide to Connecting Hardware to Flex

Web Servers• Simpler than you think

• A web server:

• Listens for connections

• Parse requests

• Send back status messages/resources requested

Tuesday, 21 June 2011

Page 39: A Practical Guide to Connecting Hardware to Flex

HTTP Requests• Start with request “GET index.html HTTP/1.1”

• Optional headers “Accept-Language: en”

• Empty line

• Optional message body (POST and other requests)

Tuesday, 21 June 2011

Page 40: A Practical Guide to Connecting Hardware to Flex

• Web server code

• Easy to modify

Ethernet Arduino Code

Tuesday, 21 June 2011

Page 41: A Practical Guide to Connecting Hardware to Flex

Ethernet Demo

Tuesday, 21 June 2011

Page 42: A Practical Guide to Connecting Hardware to Flex

ApplicationsIdeas on how and where to use this technology

Tuesday, 21 June 2011

Page 43: A Practical Guide to Connecting Hardware to Flex

Environmental Monitoring• Indoors or outdoors

• Wide range of sensors

• Sleep mode/low power consumption

Tuesday, 21 June 2011

Page 44: A Practical Guide to Connecting Hardware to Flex

Home Automation• Power and utilities monitoring

• Controlling Lights and Heating/Cooling

• Garden watering/monitoring

Tuesday, 21 June 2011

Page 45: A Practical Guide to Connecting Hardware to Flex

Security and Safety• Security systems

• Location reporting

• Bike jackets

Tuesday, 21 June 2011

Page 46: 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

• Makes you a better programmer

Tuesday, 21 June 2011

Page 47: A Practical Guide to Connecting Hardware to Flex

It’s Fun!

Tuesday, 21 June 2011

Page 48: A Practical Guide to Connecting Hardware to Flex

Questions?Ask now, see me after the session,follow me on twitter @justinmcleanor email me at [email protected].

Code and slides can be found athttp://blog.classsoftware.com

Tuesday, 21 June 2011

Page 49: A Practical Guide to Connecting Hardware to Flex

ResourcesFinding out more information

Tuesday, 21 June 2011

Page 50: A Practical Guide to Connecting Hardware to Flex

Arduino Sites• Ardunio (http://ardunio.cc)

• Spark fun (http://www.sparkfun.com)

• Lady Ada (http://ladyada.net)

• Seeed Studio (http://www.seeedstudio.com)

• Modern Device (http://moderndevice.com)

Tuesday, 21 June 2011

Page 51: A Practical Guide to Connecting Hardware to Flex

Electronic Components Suppliers• Electric Goldmine (http://www.goldmine-elec-

products.com/)

• Digikey (http://www.digikey.com/)

• Farnell (http://ww.farnell.com/)

Tuesday, 21 June 2011

Page 52: A Practical Guide to Connecting Hardware to Flex

Other Sites• Make magazine (http://makezine.com/)

• Evil Mad Scientist (http://evilmadscientist.com)

• NYC Resistor (http://nycresistor.com)

Tuesday, 21 June 2011