diff --git a/I2C.cpp b/I2C.cpp new file mode 100644 index 0000000000000000000000000000000000000000..01a26031d9eac40e889d9a3696042110192f691c --- /dev/null +++ b/I2C.cpp @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <wiringPiI2C.h> +#include <wiringPi.h> + +#include <iostream> + +using namespace std; + +const int LED = 0x08; +const int ON = 0x01; +const int OFF = 0x00; + +int main(int argc, char const *argv[]) { + + int fd = wiringPiI2CSetup(LED); + + wiringPiI2CWrite(fd, ON); + + if (wiringPiI2CRead(fd) == ON) { + printf("LIGHT ON!\n"); + } + + delay(5000); + + wiringPiI2CWrite(fd, OFF); + + if (wiringPiI2CRead(fd) == OFF) { + printf("LIGHT OFF!\n"); + } + + return 0; +} diff --git a/Makefile b/Makefile index 3183546485e7c43e4937433e9964bb52c924b916..22a4528147bd9166997962cb382bb0101246f0d8 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ switch : compile_switch motor : compile_motor sudo ./motor +led : compile_LED + sudo ./led + # compilations compile_switch : @@ -14,8 +17,9 @@ compile_switch : compile_motor : gcc -o motor motor.c -lwiringPi +compile_LED : + g++ -o led I2C.cpp -lwiringPi .PHONY : clean clean : - rm -rf switch - rm -rf motor \ No newline at end of file + rm -rf switch motor led diff --git a/encoder.c b/encoder.c index 89ddfe35280a43bf521cd26993b01b2145175367..b7977b2b7e1731791c57a87765aa68189b222471 100644 --- a/encoder.c +++ b/encoder.c @@ -14,8 +14,8 @@ const int ENC_PIN_2A = 35; //from FPGA to ENCODER -> ouput data from encod const int ENC_PIN_2B = 34; //from FPGA to ENCODER -> ouput data from encoder const int SCK_PIN = 14; //from RASPI to FPGA -> clock signal const int SCK_PIN_FPGA = 13; //from FPGA to ENCODER -> clock signal -const int SS_BAR_1 = 2; //from RASPI to FPGA -> enable encoder -const int SS_BAR_2 = 3; //from RASPI to FPGA -> enable encoder +const int SS_BAR_1 = 10; //CE0 from RASPI to FPGA -> enable encoder +const int SS_BAR_2 = 11; //CE1 from RASPI to FPGA -> enable encoder int main(int argc, char const *argv[]) {