Advertisement
j0h

Xbox360Kinect_LED_Changer

j0h
Jul 6th, 2023
919
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.43 KB | None | 0 0
  1. //gcc -Wall -g -o "%e" "%f"  -lfreenect -lfreenect_sync  
  2. #include <libfreenect.h>
  3. #include <libfreenect_sync.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <unistd.h>  //tcgetattr
  7. #include <termios.h>
  8. //Change LED of Xbox 360 Kinect
  9. //gcc -Wall -g -o "%e" "%f"  -lfreenect -lfreenect_sync  
  10.  
  11. //functions
  12.  
  13. int getch(){
  14.   //int ch= getchar();
  15.     struct termios oldattr, newattr;
  16.     int ch;
  17.     tcgetattr(STDIN_FILENO, &oldattr);
  18.     newattr = oldattr;
  19.     newattr.c_lflag &= ~(ICANON | ECHO);
  20.     tcsetattr(STDIN_FILENO, TCSANOW, &newattr);
  21.     ch = getchar();
  22.     tcsetattr(STDIN_FILENO, TCSANOW, &oldattr);
  23.  
  24.     return ch;
  25. }
  26.  
  27. int main(){
  28.     //freenect_led_options led = (freenect_led_options) 0;
  29.         while (1){
  30.         // Check for keyboard input
  31.             char key = getch();
  32.             if(key=='0'){
  33.                 freenect_sync_set_led(0, 0);
  34.                 printf("%c LED is  off\n", key);
  35.                 }
  36.              if(key=='1'){
  37.                 freenect_sync_set_led(1, 0);
  38.                 printf("%c LED is  green \n",key);
  39.                 }
  40.              if(key=='2'){
  41.                 freenect_sync_set_led(2, 0);
  42.                 printf("%c LED is  red\n",key);
  43.                 }
  44.              if(key=='3'){
  45.                 freenect_sync_set_led(3, 0);
  46.                 printf("%c LED is  orange\n", key);
  47.                 }
  48.             if(key=='4'){
  49.                 freenect_sync_set_led(4, 0);
  50.                 printf("%c LED is flashy \n", key);
  51.                 }
  52.             else if (key == 'q'){
  53.                 printf("Exiting...\n");
  54.                 break;
  55.             }
  56.     }
  57.    
  58.     return 0;
  59.     }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement