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.
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 OTHER FUNCTIONS APART FROM * * setup() AND loop() YOU MUST DECLARE THEM HERE * * *******************************************************/ /************************** * YOUR ARDUINO CODE HERE * * ************************/ int main...