Notes on programming the Arduino:
- Main program consists of setup() to initialize and loop() for continuous operation.
- Pins are set to input by default. This is good for reading digital sensors but has really low current(ex photocells). In order to change it to output mode, call pinMode(pin#, OUTPUT)
- digitalWrite(pin#, setting) allows you to set the pin HIGH or LOW. This can output or sink 40 ma.
- Analogue inputs can be used as digital outputs in output mode. In input mode, the pull up resistor can be activated by setting the pin high. All analogue pins numbers are prefixed with ‘a’.
- It may be good to put short delays between analogue sensor reads to lower the electrical noise.
- Power width modulation is a way mimic an analogue output by digital means. The pins capable of this seem to be marked. This can be done using analogueWrite(value)
- There are 3 types of memory on the arduino, 16kb(with 2kb used for bootloader) Flash, 1024 bytes of SRAM, and 512 bytes of EEPROM. The main program resides in the flash memory while active variables are stored in the SRAM. The EEPROM memory is non-volatile and can be used to hold states between power downs.
- One way to save memory is to use #define for constants. Using this instead of declaring variables, save memory by replacing all instances of the constant on compile for it doesn’t have to sit in memory. You can also store constants in the program memory using the PROGMEM keyword.
- Libraries: http://arduino.cc/en/Reference/Libraries
