wyatt8740

arduino snes controller 1

May 25th, 2015
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.42 KB | None | 0 0
  1. /*
  2.             (latch)
  3.  _______________|___________________________
  4. |  5v  clock strobe data |              GND  \
  5. | ( )   ( )   ( )   ( )  |  ( )   ( )   ( )  )
  6. |________________________|__________________/
  7.  
  8.  
  9.  
  10. wire colors for knockoff pelican controller cable:
  11. 5v..............black
  12. ground..........brown
  13. clock...........blue
  14. strobe/latch....white
  15. data............green
  16.  
  17. */
  18. /* define the pin numbers */
  19.   #define SNSDATA  2
  20.   #define SNSLATCH 7
  21.   #define SNSCLOCK 8
  22.  
  23. // the setup function runs once when you press reset or power the board
  24.   //shift register needs to send 16 bits, so two bytes  
  25.   int byte1;
  26.   int byte2;
  27.  
  28.   int getReady;
  29.  
  30. void setup() {
  31.   pinMode(SNSDATA, OUTPUT);
  32.   pinMode(SNSLATCH, INPUT);
  33.   pinMode(SNSCLOCK, INPUT);
  34.   //status LED
  35.   pinMode(13,OUTPUT);
  36.   //the controller bits. they are 0x1 when HIGH, and when HIGH are paradoxically turned off.
  37.   //THIS IS TOTALLY INEFFICIENT/BAD HOW I DID THIS, I THINK.
  38.  
  39.   digitalWrite(SNSDATA,HIGH); //set all controls to not pressed before beginning
  40. }
  41.  
  42. void loop(){
  43.   if(digitalRead(SNSLATCH)==HIGH){
  44.     getReady=1;
  45.   }
  46.   while(getReady==1){
  47.     if(digitalRead(SNSLATCH)==LOW){
  48.       //start doing stuff
  49.       //
  50.   }
  51.  
  52. }
  53.  
  54.  
  55.   /*
  56. byte1:
  57.   bits:
  58.  
  59.   0  b
  60.   1  y
  61.   2  select
  62.   3  start
  63.   4  up
  64.   5  down
  65.   6  left
  66.   7  right
  67.  
  68.  
  69. byte2:
  70.   bits:
  71.  
  72.   0  a
  73.   1  x
  74.   2  l
  75.   3  r
  76.   4  ?
  77.   5  ?
  78.   6  ?
  79.   7  ?
  80.   */
Advertisement
Add Comment
Please, Sign In to add comment