Hardware Reference
In-Depth Information
This approach has the benefit of making the
pinMode
set the default value as needed. Also, using the internal
pull-up resistors removes the need to use external pull-up resistors, allowing you to remove parts from your project.
Return Types
Return types have been updated to return the size of data using
size_t
, which is an unsigned integer that is platform
dependent.
size_t
is included from
stdio.h
in the
Print.h
header. This returns a size type for the data printed.
You can use this to check the quantity of data returned for iterating. When writing your own libraries that print custom
data, you would use
size_t
as the return value.
uint_8
Several functions now take and return
uint_8
, which is a universal 8-bit integer that allows for cross-platform
compatibility.
Arduino API Core 1.0.4
Now let's look at the changes in the Arduino API Core.
Arduino.h
If you are using standard AVR GCC system libraries or writing your own library, it's important to know the Arduino
library.
Arduino.h
now includes all the values from
wiring.h
. If you are already programming with C/C++, it's good to
know which functions are already available, so that you don't include the libraries twice.
Arduino.h
includes the libraries shown in Listing 1-2, so you don't need to include them in your own sketches.
Listing 1-2.
New Headers Automatically Included in Arduino.h
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <avr/pgmspace.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include "binary.h"
#include "WCharacter.h"
#include "WString.h"
#include "HardwareSerial.h"
#include "pins_arduino.h"
You never have to duplicate the libraries in your own sketches. They are automatically included for your use.
The preprocessing compiles
Arduino.h
, and then combines the sketch with a file called
main.cpp
. This file
contains the implementation for
void setup()
and
void loop()
. In fact, it's short enough to show in Listing 1-3.