/****************************************************************** * Filename: 3-Way.c * * An Arduino controls the tri color LED attached to the RaspberryPi * through a level shifter, an optocoupler, and a voltage divider. * * This demonstrates three ways to step the five volt signal from * the Arduino down to the 3.3 volts required for the RaspberryPi. * * Use the _3_Way.ino program to send the signal from the Arduino. ******************************************************************/ #include #include int main (void) { wiringPiSetup(); // Enable wiringPi. pinMode(0, INPUT); // Level Shifter, input. pinMode(2, INPUT); // Optocoupler, input. pinMode(3, INPUT); // Voltage Divider, input. pinMode(6,OUTPUT); // Level Shifter LED, output. pinMode(10,OUTPUT); // Optocoupler LED, output. pinMode(11,OUTPUT); // Voltage Divider LED, output. while(1) { digitalWrite(6, !digitalRead(0)); // Level Shifter digitalWrite(10,!digitalRead(2)); // Optocoupler digitalWrite(11,!digitalRead(3)); // Voltage Divider } return 0; }