Hardware Reference
In-Depth Information
Figure 6-3.
Cooking Hacks' Raspberry Pi to Arduino shields connection bridge
Cooking Hacks includes the
schematic as a PDF download
on its website.
Using the arduPi Library
arduPi is a C++ library that lets you write programs for Raspberry Pi as if you were
writing an Arduino program. All the functions that control serial port communications,
I2C, SPI, and GPIO pins are available using the Arduino syntax. The available library
functions are listed in
Table 6-1
.
To get started, first
download the arduPi library
. In the library folder you will find three
files:
arduPi.cpp
,
arduPi.h
, and
arduPi_template.cpp
. The
arduPi_template.cpp
file is
meant to be used as a starting point to create programs with the same behavior as
an Arduino program.
Table 6-1.
ArduiPi library functions
SERIAL LIBRARY FUNCTIONS
WIRE LIBRARY FUNCTIONS
SPI LIBRARY FUNCTIONS
available()
begin()
begin()
begin()
requestFrom()
end()
end()
beginTransmission()
setBitOrder()
flush()
endTransmission()
setClockDivider()
peek()
write()
setDataMode()
print()
read()
transfer()
println()