5. Programming
Data types
When variables are made to exceed their maximum capacity they "roll over" back to their minimum capacity, note that this happens in both
directions.
int x
x = -32,768;
x = x - 1; // x now contains 32,767 - rolls over in neg. direction
x = 32,767;
x = x + 1; // x now contains -32,768 - rolls over
Float & casting:
6. Programming
Float & casting:
int x;
int y;
float z;
x = 1;
y = x / 2; // y now contains 0, ints can't hold fractions
z = (float)x / 2.0; // z now contains .5 (you have to use 2.0, not 2)
7. Resources
• Language reference:
• http://www.arduino.cc/en/Reference/HomePage
• http://arduino.cc/en/Reference/Extended
• General code library:
• http://arduino.cc/en/Reference/Libraries
• Interfacing with hardware:
• http://www.arduino.cc/playground/Main/InterfacingWithHardware
• Examples
• http://arduino.cc/en/Tutorial/HomePage
9. Analogue sensor pins
• Use analogue in pins 0-5 for analogRead()
• Address as 14-19 when used as digital pins
• digitalWrite(), digitalRead()
• No pinMode required for analogRead();
15. Calibration - part 2
• map(): remap a number from one range to another
• val = map(val, 0, 1023, 0, 255);
• constrain(): constrain to a number range
24. This session of the workshop will
show you some ways of doing that.
25. Arduino to the world
• Arduino direct to Pachube via ethernet/wifi
shield
• Or Arduino to PC via serial, then to
Pachube/Twitter
• We’re taking the second approach in this
workshop, since the kits we provided don’t
include ethernet/wifi shields
37. What next?
• Hackerspace Brisbane
• http://hackerspaces.org/wiki/Hackerspace_Brisbane
• Living Dolls (The Edge)
• http://edgeqld.org.au/blog/2011/04/07/living-dolls/