Shield Documentation Arduino Playground Arduino Shield List
All posts by
Heartbeat Timer
A Example Heartbeat Timer In your apps main loop HeartbeatTimer(); The Heartbeat Function //******************************* //******************************* //********** HEARTBEAT ********** //******************************* //******************************* void HeartbeatTimer() { static byte heartbeat_10ms_timer = 0; static byte heartbeat_100ms_timer = 0; static unsigned long heartbeat_last_1ms_time = 0; while ((micros() – heartbeat_last_1ms_time) >= 1000) //micros() provides exact 1mS timing, millis() does not! { //——————————- […]
Arduino Timers
millis() Continuous running mS timer. Rolls over back to zero. unsigned long In our test millis did not provide exact 1mS timing, whereas using micros x 1000 did. micros() Continuous running unsigned long uS timer. Rolls over back to zero. unsigned long
Creating A Library
Library Files A library contains a .h header file and a .c or .cpp source code file as a minimum. Additional files can be added as needed. The files should used inside a directory typically given the library name. Create a .h File #ifndef MY_LIBRARY_H //Do only once the first time this file is used #define MY_LIBRARY_H […]
Arduino Libraries
The Arduino Libraries http://arduino.cc/en/Reference/Libraries Where are libraries stored Default libraries Libraries you add
Analog Inputs
10 bit AtoD returning integers from 0 to 1023. Read Analog Input There is no need to set the pin up as an analog input, just start reading it: Setting The Analog Reference Voltage Use the analogReference() function; DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino […]
Constants
Creating A Constant const int ledPin = 13; Storing constants in Program Memory instead of RAM You need to use the PROGMEM modifier – see here. Reading the values also requies special handling by using pgm_read_byte_near() or pgm_read_word_near()
PWM Outputs
Using PWM Output Pins To set the PWM period on any pin which can be used for PWM use the following: There is no need to set the pin as an output as it will be automatically set as one. The PWM frequency is fixed at approximately 490 Hz. Boards With > 8 Bit PWM […]
Functions General
Creating A Function void MyFunction() { } There is no need for a function definition as in C.
Serial Port (UART)
Arduino Serial Ports UART0 is the default serial port which is used for serial programming. Some arduino’s have more than one serial port and these are called Serial1, Serial2, etc Setup Serial Port Sending ASCII Text Sending Variables As ASCII Others see here. Write Binary Data Receive Binary Data
