Cover by Andrew K. Dennis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Setting up our software

Let's start with writing a simple program that opens and closes a relay connected to the Raspberry Pi. Once we have confirmed this works we can then modify the application we wrote in the previous chapter to switch the relays on and off and construct a URL to post the data to the web.

A program to test the relay

Load up Geany and add the following program to a file called Relay.cpp in the same directory as your arduPi library:

//Include ArduPi library #include "arduPi.h" //Needed for Serial communication SerialPi Serial; //Needed for accesing GPIO (pinMode, digitalWrite, digitalRead, I2C functions) WirePi Wire; //Needed for SPI SPIPi SPI; /********************************************************* * IF YOUR ARDUINO CODE HAS ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required