0% found this document useful (0 votes)
231 views

Arduino & ActionScript

This document provides an overview of Arduino and how to interface it with ActionScript. Arduino is an open-source hardware and software platform for building interactive objects and environments. It allows users to read sensor input and control motors and lights through an easy programming environment. The document explains what Arduino is, how to write basic Arduino programs, and how to connect Arduino to ActionScript using libraries like serproxy or Firmata that allow communication over a serial connection.

Uploaded by

orgicus
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
231 views

Arduino & ActionScript

This document provides an overview of Arduino and how to interface it with ActionScript. Arduino is an open-source hardware and software platform for building interactive objects and environments. It allows users to read sensor input and control motors and lights through an easy programming environment. The document explains what Arduino is, how to write basic Arduino programs, and how to connect Arduino to ActionScript using libraries like serproxy or Firmata that allow communication over a serial connection.

Uploaded by

orgicus
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Arduino & ActionScript

GeorgeProfenza

Who am I (today) ?

I am George Profenza
I do R&D at disturb media http://disturbmedia.com

I graduated from the Creative Computing course at Goldsmiths, University of London, where we had the Physical Computing course with the awesome Daniel Hirschmann

http://creativecomputation.co.uk http://www.danielhirschmann.com

What is Physical Computing ?


Marrying the analog world with the digital world

What is Physical Computing ?


Marrying the analog world with the digital world It happens all around us. Were surrounded by sensors and actuators
Sensors: Light Temperature Distance Rotation Pressure Knock Actuators/motors: Servo DC Stepper

credits: winjohn, sxc.hu (http://www.sxc.hu/photo/645188)

credits: http://www.kalipedia.com

What is Physical Computing ?


Marrying the analog world with the digital world

credits: University of Portsmouth, Department of Electronic and Computer Engineering

credits: Interactive Environments Lab (http://medialappi.net/lab/)

What is Arduino ?

"Arduino is an open-source electronics prototyping platform based on exible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments." arduino.cc

What is Arduino ?

"Arduino is an open-source electronics prototyping platform based on exible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments." arduino.cc

Arduino = Hardware + Software

What is Arduino ?
digital pins

serial to USB power select jumper DC in power analog pins

What is Arduino ?

1. Type code in the IDE 2. Upload it on the board through USB

Bruce by Tom Judd http://vimeo.com/5138697

What is Arduino ?
The Arduino IDE

built on Processing code editor, tools + terminal included syntax is simplied C


Most of the code youll need in one slide:

pinMode(); digitalRead() / digitalWrite() analogRead() / analogWrite() delay() / millis() Serial.begin() / Serial.print()

What can you do with it ?


http://learn.plankman.com/w/index.php?title=Goldsmiths,_Autumn_2009

Mini Weather Station Arduino Synthesiser How are you ? Light driven robot Project Monster - Big Eye More cool stuff in the Resources slides

Hello World
void setup(){//runs once pinMode(11,OUTPUT);//set pin 11 as output } void loop(){//runs over and over again, like ENTER_FRAME digitalWrite(11,HIGH);//turn pin 11 ON delay(500);//wait digitalWrite(11,LOW);//turn pin 11 OFF delay(500);//wait }

http://arduino.cc/en/Tutorial/Blink

Hello World
void setup() { Serial.begin(9600); } void loop() { int sensorValue = analogRead(0); Serial.println(sensorValue, DEC); }

PWMLED
int ledPin = 9; void setup() { Serial.begin(9600); pinMode(ledPin,INPUT); } void loop() { int sensorValue = analogRead(0); Serial.println(sensorValue, DEC); analogWrite(ledPin,int(sensorValue * 0.25)); }

IR Range
//for details see: http://www.acroname.com/robotics/info/articles/irlinear/irlinear.html //k constant works for Sharp 2Y0A02 range sensor 20-150 cm oat k = 1.02f; oat value = 0.0f; void setup(){ Serial.begin(9600); } void loop(){ value = (1/(oat(analogRead(0))/1024.0f) + k) * 10; Serial.println(value); }

Flash Blink
/* Orginial code by Mike Chambers see details here: http://www.mikechambers.com/ blog/2010/08/04/gettingstarted-with-ash-and-arduino/ */ #dene LED_PIN 13 #dene TOGGLE_LED_STATE 't' #dene EOL_DELIMITER "\n" int incoming = 0; int wait = 500; boolean shouldBlinkLED = false; void setup() { Serial.begin(9600); Serial.print("INITIALIZING"); Serial.print(EOL_DELIMITER); pinMode(LED_PIN, OUTPUT); blinkLED(5); Serial.print("READY"); Serial.print(EOL_DELIMITER); }

Flash Blink
void loop() { if(shouldBlinkLED) blinkLED(1); if(Serial.available() > 0){ incoming = Serial.read(); if(incoming == TOGGLE_LED_STATE){ shouldBlinkLED = !shouldBlinkLED; Serial.print("LED BLINK STATE: "); if(shouldBlinkLED) Serial.print("ON"); else Serial.print("OFF"); Serial.print(EOL_DELIMITER); } } } void blinkLED(int count){ for(int i = 0; i < count; i++){ digitalWrite(LED_PIN, HIGH); delay(wait); digitalWrite(LED_PIN, LOW); delay(wait); } }

Pulse Width Modulation


"Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means." http://www.arduino.cc/en/Tutorial/PWM

Interfacing

Interfacing with Actionscript Using serproxy Arduino setup - sends messages through serial serproxy setup - make sure baud rate and board match(cfg) open up serproxy.cfg in a text edit set the serial_device to your device port (Tools>Serial Ports) set the baud rate Flash setup - open a binary socket and read/write values

Interfacing

Firmata "Firmata a generic protocol for communicating with microcontrollers like the Arduino from software on a host computer. " arduino.cc

Interfacing
Alternatively for as3 use as3glue, uses Firmata tutorial here: http://blog.jvers.com/?tag=ash-as3glue-arduino-rmata-pcomp

Recap
Arduino: digital pins setup input - pinMode(pinNo, INPUT); output - pinMode(pinNo, OUTPUT); reading values (0 - 1024) analog - analogRead(analogPinNo); digital - digitalRead(digitalPinNo); writing values (0 - 256) analog - analogWrite(pin,value); digital - digitalWrite(pin,value); serial Serial.begin(baudRate); Serial.print();Serial.println(); PWM is NOT affected by delay() - internal timer

Recap
Arduino.cc (tutorials/forums) Plankman wiki / Physical Computing list components: UK: cool components,rapidonline etc US,Germany,etc: adafruit,sparkfun electronics other Arduino compatible boards Freeduino Seeduino other Boards Phidget fun projects hack-a-day

[email protected] www.arduino.cc www.disturbmedia.com

You might also like