Advertisement
Guest User

wiring

a guest
Jun 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <errno.h>
  4. #include <wiringPiSPI.h>
  5. #include <unistd.h>
  6.  
  7. using namespace std;
  8.  
  9. // channel is the wiringPi name for the chip select (or chip enable) pin.
  10. // Set this to 0 or 1, depending on how it's connected.
  11. static const int CHANNEL = 1;
  12.  
  13. int main()
  14. {
  15. int fd, result;
  16. unsigned char buffer[3];
  17.  
  18. cout << "Initializing" << endl ;
  19.  
  20. // Configure the interface.
  21. // CHANNEL insicates chip select,
  22. // 500000 indicates bus speed.
  23. fd = wiringPiSPISetup(CHANNEL, 500000);
  24.  
  25. cout << "Init result: " << fd << endl;
  26.  
  27. // clear display
  28. buffer[0] = 0xFF;
  29.  
  30. while(1)
  31. {
  32. wiringPiSPIDataRW(CHANNEL, buffer, 1);
  33.  
  34. sleep(100);
  35. }
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement