Adding A Library

Adding A Library Using the IDE Library Manager Open the Arduino library manager:  Menu > Sketch > Include Library > Manage Libraries Adding A Library For All Projects On Windows Copy the library directory into the folder: My Documents /Arduino/libraries/ On A Mac Copy the library directory into the folder: ~/Documents/Arduino/libraries/ Restart the Arduino IDE and the library […]

Read More

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! { //——————————- […]

Read More

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

Read More

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 […]

Read More

Arduino Libraries

The Arduino Libraries http://arduino.cc/en/Reference/Libraries Where are libraries stored Default libraries Libraries you add

Read More

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 […]

Read More

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()  

Read More

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 […]

Read More