Advertisement
Guest User

Untitled

a guest
Aug 26th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. //============================================================================
  2. // Name : TestApp.cpp
  3. // Author : Norbi
  4. // Version :
  5. // Copyright : Hmm
  6. // Description : Hello World in C++, Ansi-style
  7. //============================================================================
  8.  
  9. #include <iostream>
  10. #include <stdio.h>
  11. using namespace std;
  12.  
  13. int main() {
  14. cout << "Motor driver starts" << endl; // prints !!!Hello World!!!
  15. FILE *LEDHandle = NULL;
  16. char *LEDBrightness = "/sys/class/leds/beaglebone:green:usr3/brightness";
  17.  
  18. for(int i=0; i<10; i++){
  19. if((LEDHandle=fopen(LEDBrightness,"r+"))=NULL){
  20.  
  21. fwrite("1",sizeof(char),1,LEDHandle);
  22. fclose(LEDHandle);
  23. sleep(1);
  24. }else{
  25. cout << "cant work with the led" << endl;
  26.  
  27. }
  28. if((LEDHandle=fopen(LEDBrightness,"r+"))=NULL){
  29.  
  30. fwrite("0",sizeof(char),1,LEDHandle);
  31. fclose(LEDHandle);
  32. sleep(1);
  33. }else{
  34. cout << "cant work with the led" << endl;
  35.  
  36. }
  37.  
  38. }
  39.  
  40. cout << "Motor driver stops" << endl;
  41. return 0;
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement