Category Archives: Resources

The Map Function

Here is a function that may be useful for many of the projects.

map(value, fromLow, fromHigh, toLow, toHigh)
http://arduino.cc/en/reference/map

Here is a diagram of how this function works

map1

The function takes a value that is in the range of fromHigh to fromLow.  It then remaps the value to toHigh to toLow.

One very nice applicatin of this technique is for remapping analog input to analog output.

void loop()
{
int val = analogRead(0);
val = map(val, 0, 1023, 0, 255);
analogWrite(9, val);
}
Another interesting aspect of this function is that it allows us to flip the lows and highs as shown in the diagram below.

map2This may be really useful for items such as the RGB LED that work by driving a signal low.

Arduino Language Reference

Here is a link for the functions of the arduino programming language.

http://arduino.cc/en/Reference/HomePage

Structure

Control Structures

Further Syntax

Arithmetic Operators

  • = (assignment operator)
  •  (addition)
  •  (subtraction)
  • * (multiplication)
  • / (division)
  • % (modulo)

Comparison Operators

  • == (equal to)
  • != (not equal to)
  • < (less than)
  • > (greater than)
  • <= (less than or equal to)
  • >= (greater than or equal to)

Boolean Operators

  • && (and)
  • || (or)
  • ! (not)

Pointer Access Operators

Bitwise Operators

  • & (bitwise and)
  • | (bitwise or)
  • ^ (bitwise xor)
  • ~ (bitwise not)
  • << (bitshift left)
  • >> (bitshift right)

Compound Operators

  • ++ (increment)
  •  (decrement)
  • += (compound addition)
  • -= (compound subtraction)
  • *= (compound multiplication)
  • /= (compound division)
  • &= (compound bitwise and)
  • |= (compound bitwise or)

Variables

Constants

Data Types

Conversion

Variable Scope & Qualifiers

Utilities

Functions

Digital I/O

Analog I/O

Due only

Advanced I/O

Time

Math

Trigonometry

Random Numbers

Bits and Bytes

External Interrupts

Interrupts

Communication

USB (Leonardo and Due only)

Items you need for class

We recommend the following hardware for the class:

ProtoSnap – LilyPad Development Board
https://www.sparkfun.com/products/11262
or similar microcontroller, LEDs, sensors, etc

USB mini-B
https://techstore.doit.wisc.edu/product.asp?login=P&itemnum=C55533
for the microcontroller

Embroidery Hoop
Example: http://www.joann.com/8in-wood-embroidery-hoop-with-round-edges-/12212486.html?green=6D3E039F-7D35-5FBC-A505-CD9DF7050619

Fabric Marker
Example:http://www.michaels.com/apparel-crafts/fabric-markers/807060426

Fabric
Of your choice.

Needle Threader
Example: http://www.connectingthreads.com/Tools/Double_Needle_Threader__D82128.HTML?gclid=CJX1gOjJvsACFQkQaQod2goASA

Something to hold your supplies
Example: http://www.newegg.com/Product/Product.aspx?Item=9SIA0601R11315&nm_mc=KNC-GoogleMKP&cm_mmc=KNC-GoogleMKP-_-pla-_-Garage+Storage+%26+Tool+Cabinets-_-9SIA0601R11315&ef_id=r3xOFM08tUYAAEvo:20140902152351:s