/* PSConSerial (c)2011 kou029w - MIT License [http://kou029w.appspot.com/mit-license.txt] PSCon Arduino CLK 13 SCK SEL 10 SS CMD 11 MOSI DAT 12 MISO */ #include #define PIN_CLK 13 #define PIN_SEL 10 #define PIN_CMD 11 #define PIN_DAT 12 PSCon PSCon; byte requestData[] = {0x42,0,0,0,0,0,0,0}; void setup(){ Serial.begin(9600); PSCon.clkPin(PIN_CLK); PSCon.selPin(PIN_SEL); PSCon.cmdPin(PIN_CMD); PSCon.datPin(PIN_DAT); } void loop(){ PSCon.get(requestData); if(PSCon.data[0] == 0x73){ // デジコン:0x41, アナコン:0x73 Serial.print("R(x,y):("); Serial.print(PSCon.data[4], DEC); // 左が0x00, 右が0xFF Serial.print(","); Serial.print(PSCon.data[5], DEC); // 上が0x00, 下が0xFF Serial.print(") "); Serial.print("L(x,y):("); Serial.print(PSCon.data[6], DEC); // 左が0x00, 右が0xFF Serial.print(","); Serial.print(PSCon.data[7], DEC); // 上が0x00, 下が0xFF Serial.print(") "); } if(~PSCon.data[2] & 0x01<<0)Serial.print("sel "); if(~PSCon.data[2] & 0x01<<1)Serial.print("L3 "); if(~PSCon.data[2] & 0x01<<2)Serial.print("R3 "); if(~PSCon.data[2] & 0x01<<3)Serial.print("sta "); if(~PSCon.data[2] & 0x01<<4)Serial.print("^ "); if(~PSCon.data[2] & 0x01<<5)Serial.print("> "); if(~PSCon.data[2] & 0x01<<6)Serial.print("v "); if(~PSCon.data[2] & 0x01<<7)Serial.print("< "); if(~PSCon.data[3] & 0x01<<0)Serial.print("L2 "); if(~PSCon.data[3] & 0x01<<1)Serial.print("R2 "); if(~PSCon.data[3] & 0x01<<2)Serial.print("L1 "); if(~PSCon.data[3] & 0x01<<3)Serial.print("R1 "); if(~PSCon.data[3] & 0x01<<4)Serial.print("% "); if(~PSCon.data[3] & 0x01<<5)Serial.print("O "); if(~PSCon.data[3] & 0x01<<6)Serial.print("X "); if(~PSCon.data[3] & 0x01<<7)Serial.print("# "); Serial.println(); delay(16); }