Skip to content
Extraits de code Groupes Projets
Valider 01d2e8eb rédigé par Diego de Bernard de Fauconval's avatar Diego de Bernard de Fauconval
Parcourir les fichiers

code led I2C ok

parent 204f2c19
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
#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;
}
...@@ -6,6 +6,9 @@ switch : compile_switch ...@@ -6,6 +6,9 @@ switch : compile_switch
motor : compile_motor motor : compile_motor
sudo ./motor sudo ./motor
led : compile_LED
sudo ./led
# compilations # compilations
compile_switch : compile_switch :
...@@ -14,8 +17,9 @@ compile_switch : ...@@ -14,8 +17,9 @@ compile_switch :
compile_motor : compile_motor :
gcc -o motor motor.c -lwiringPi gcc -o motor motor.c -lwiringPi
compile_LED :
g++ -o led I2C.cpp -lwiringPi
.PHONY : clean .PHONY : clean
clean : clean :
rm -rf switch rm -rf switch motor led
rm -rf motor
\ No newline at end of file
...@@ -14,8 +14,8 @@ const int ENC_PIN_2A = 35; //from FPGA to ENCODER -> ouput data from encod ...@@ -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 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 = 14; //from RASPI to FPGA -> clock signal
const int SCK_PIN_FPGA = 13; //from FPGA to ENCODER -> 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_1 = 10; //CE0 from RASPI to FPGA -> enable encoder
const int SS_BAR_2 = 3; //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[]) int main(int argc, char const *argv[])
{ {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter