Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- (latch)
- _______________|___________________________
- | 5v clock strobe data | GND \
- | ( ) ( ) ( ) ( ) | ( ) ( ) ( ) )
- |________________________|__________________/
- wire colors for knockoff pelican controller cable:
- 5v..............black
- ground..........brown
- clock...........blue
- strobe/latch....white
- data............green
- */
- /* define the pin numbers */
- #define SNSDATA 2
- #define SNSLATCH 7
- #define SNSCLOCK 8
- // the setup function runs once when you press reset or power the board
- //shift register needs to send 16 bits, so two bytes
- int byte1;
- int byte2;
- int getReady;
- void setup() {
- pinMode(SNSDATA, OUTPUT);
- pinMode(SNSLATCH, INPUT);
- pinMode(SNSCLOCK, INPUT);
- //status LED
- pinMode(13,OUTPUT);
- //the controller bits. they are 0x1 when HIGH, and when HIGH are paradoxically turned off.
- //THIS IS TOTALLY INEFFICIENT/BAD HOW I DID THIS, I THINK.
- digitalWrite(SNSDATA,HIGH); //set all controls to not pressed before beginning
- }
- void loop(){
- if(digitalRead(SNSLATCH)==HIGH){
- getReady=1;
- }
- while(getReady==1){
- if(digitalRead(SNSLATCH)==LOW){
- //start doing stuff
- //
- }
- }
- /*
- byte1:
- bits:
- 0 b
- 1 y
- 2 select
- 3 start
- 4 up
- 5 down
- 6 left
- 7 right
- byte2:
- bits:
- 0 a
- 1 x
- 2 l
- 3 r
- 4 ?
- 5 ?
- 6 ?
- 7 ?
- */
Advertisement
Add Comment
Please, Sign In to add comment