road to japan
Dependencies: DigitDisplay Motor PID Ping mbed millis
Fork of MainProgram_BaseBaru_fix_omni_20April by
PS3Arduino.txt@47:6cac4f1a3c8e, 2017-05-13 (annotated)
- Committer:
- Najib_irvani
- Date:
- Sat May 13 05:47:10 2017 +0000
- Revision:
- 47:6cac4f1a3c8e
- Parent:
- 46:85169ae8659b
road to japan
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Najib_irvani | 46:85169ae8659b | 1 | /*********************************************************************************************/ |
Najib_irvani | 46:85169ae8659b | 2 | /** **/ |
Najib_irvani | 46:85169ae8659b | 3 | /** PROGRAM KOMUNIKASI DATA JOYSTIK PS3 **/ |
Najib_irvani | 46:85169ae8659b | 4 | /** **/ |
Najib_irvani | 46:85169ae8659b | 5 | /** Joystik PS3 -> Arduino -> STM32Nucleo **/ |
Najib_irvani | 46:85169ae8659b | 6 | /** **/ |
Najib_irvani | 46:85169ae8659b | 7 | /** Fanny Achmad Hindrarta **/ |
Najib_irvani | 46:85169ae8659b | 8 | /** EL'12 - 13212076 **/ |
Najib_irvani | 46:85169ae8659b | 9 | /** **/ |
Najib_irvani | 46:85169ae8659b | 10 | /** Last Update : 01 Februar1 2015, 20.30 **/ |
Najib_irvani | 46:85169ae8659b | 11 | /*********************************************************************************************/ |
Najib_irvani | 46:85169ae8659b | 12 | |
Najib_irvani | 46:85169ae8659b | 13 | #include <PS3BT.h> |
Najib_irvani | 46:85169ae8659b | 14 | #include <usbhub.h> |
Najib_irvani | 46:85169ae8659b | 15 | //#include <PS3USB.h> |
Najib_irvani | 46:85169ae8659b | 16 | #include "Arduino.h" |
Najib_irvani | 46:85169ae8659b | 17 | // Satisfy IDE, which only needs to see the include statment in the ino. |
Najib_irvani | 46:85169ae8659b | 18 | #ifdef dobogusinclude |
Najib_irvani | 46:85169ae8659b | 19 | #include <spi4teensy3.h> |
Najib_irvani | 46:85169ae8659b | 20 | #endif |
Najib_irvani | 46:85169ae8659b | 21 | |
Najib_irvani | 46:85169ae8659b | 22 | |
Najib_irvani | 46:85169ae8659b | 23 | USB Usb; |
Najib_irvani | 46:85169ae8659b | 24 | |
Najib_irvani | 46:85169ae8659b | 25 | // Bluetooth |
Najib_irvani | 46:85169ae8659b | 26 | // You can create the instance of the class in two ways |
Najib_irvani | 46:85169ae8659b | 27 | BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so |
Najib_irvani | 46:85169ae8659b | 28 | //You can create the instance of the class in two ways |
Najib_irvani | 46:85169ae8659b | 29 | PS3BT PS3(&Btd); // This will just create the instance |
Najib_irvani | 46:85169ae8659b | 30 | //PS3BT PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch |
Najib_irvani | 46:85169ae8659b | 31 | /* |
Najib_irvani | 46:85169ae8659b | 32 | // USB |
Najib_irvani | 46:85169ae8659b | 33 | // You can create the instance of the class in two ways |
Najib_irvani | 46:85169ae8659b | 34 | PS3USB PS3(&Usb); // This will just create the instance |
Najib_irvani | 46:85169ae8659b | 35 | //PS3USB PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch |
Najib_irvani | 46:85169ae8659b | 36 | */ |
Najib_irvani | 46:85169ae8659b | 37 | |
Najib_irvani | 46:85169ae8659b | 38 | boolean printAngle; |
Najib_irvani | 46:85169ae8659b | 39 | uint8_t state = 0; |
Najib_irvani | 46:85169ae8659b | 40 | |
Najib_irvani | 46:85169ae8659b | 41 | // Deklarasi tombol |
Najib_irvani | 46:85169ae8659b | 42 | boolean kiri_click=0, kanan_click=0, atas_click=0, bawah_click=0; |
Najib_irvani | 46:85169ae8659b | 43 | boolean segitiga_click=0, lingkaran_click=0, kotak_click=0, silang_click=0; |
Najib_irvani | 46:85169ae8659b | 44 | boolean L1_click=0, R1_click=0, L3_click=0, R3_click=0; |
Najib_irvani | 46:85169ae8659b | 45 | boolean START_click=0, SELECT_click=0, PS_click=0; |
Najib_irvani | 46:85169ae8659b | 46 | |
Najib_irvani | 46:85169ae8659b | 47 | // Deklarasi variabel tombol analog |
Najib_irvani | 46:85169ae8659b | 48 | unsigned char LX, LY, RX, RY, aL2, aR2; |
Najib_irvani | 46:85169ae8659b | 49 | |
Najib_irvani | 46:85169ae8659b | 50 | // Deklarasi varibel data yang dikirim |
Najib_irvani | 46:85169ae8659b | 51 | unsigned char button; |
Najib_irvani | 46:85169ae8659b | 52 | unsigned char RL; |
Najib_irvani | 46:85169ae8659b | 53 | unsigned int button_click; |
Najib_irvani | 46:85169ae8659b | 54 | unsigned int RL_click; |
Najib_irvani | 46:85169ae8659b | 55 | |
Najib_irvani | 46:85169ae8659b | 56 | void setup_joystik() |
Najib_irvani | 46:85169ae8659b | 57 | { |
Najib_irvani | 46:85169ae8659b | 58 | while (!Serial) // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection |
Najib_irvani | 46:85169ae8659b | 59 | { |
Najib_irvani | 46:85169ae8659b | 60 | Serial.write(0x88); |
Najib_irvani | 46:85169ae8659b | 61 | Serial.write(0x09); |
Najib_irvani | 46:85169ae8659b | 62 | } |
Najib_irvani | 46:85169ae8659b | 63 | if (Usb.Init() == -1) { |
Najib_irvani | 46:85169ae8659b | 64 | //Serial.print(F("\r\nOSC did not start")); |
Najib_irvani | 46:85169ae8659b | 65 | while (1) //halt |
Najib_irvani | 46:85169ae8659b | 66 | { |
Najib_irvani | 46:85169ae8659b | 67 | Serial.write(0x88); |
Najib_irvani | 46:85169ae8659b | 68 | Serial.write(0x09); |
Najib_irvani | 46:85169ae8659b | 69 | } |
Najib_irvani | 46:85169ae8659b | 70 | } |
Najib_irvani | 46:85169ae8659b | 71 | //Serial.print(F("\r\nPS3 USB Library Started")); |
Najib_irvani | 46:85169ae8659b | 72 | } |
Najib_irvani | 46:85169ae8659b | 73 | |
Najib_irvani | 46:85169ae8659b | 74 | /*********************************************************************************************/ |
Najib_irvani | 46:85169ae8659b | 75 | /** **/ |
Najib_irvani | 46:85169ae8659b | 76 | /** FUNGSI PENGIRIMAN DATA **/ |
Najib_irvani | 46:85169ae8659b | 77 | /** - Data yang akan dikirim adalah paket data 8-bit dengan urutan sebagai berikut **/ |
Najib_irvani | 46:85169ae8659b | 78 | /** |------|------|--------|----|--------------|----------|----|----|----|----|----|----| **/ |
Najib_irvani | 46:85169ae8659b | 79 | /** | 0x88 | 0x08 | button | RL | button_click | RL_click | R2 | L2 | RX | RY | LX | LY | **/ |
Najib_irvani | 46:85169ae8659b | 80 | /** |------|------|--------|----|--------------|----------|----|----|----|----|----|----| **/ |
Najib_irvani | 46:85169ae8659b | 81 | /** **/ |
Najib_irvani | 46:85169ae8659b | 82 | /*********************************************************************************************/ |
Najib_irvani | 46:85169ae8659b | 83 | |
Najib_irvani | 46:85169ae8659b | 84 | void kirimdatajoystik() |
Najib_irvani | 46:85169ae8659b | 85 | { |
Najib_irvani | 46:85169ae8659b | 86 | |
Najib_irvani | 46:85169ae8659b | 87 | Serial.write(0x88); |
Najib_irvani | 46:85169ae8659b | 88 | Serial.write(0x08); |
Najib_irvani | 46:85169ae8659b | 89 | Serial.write(button); |
Najib_irvani | 46:85169ae8659b | 90 | Serial.write(RL); |
Najib_irvani | 46:85169ae8659b | 91 | Serial.write(button_click); |
Najib_irvani | 46:85169ae8659b | 92 | Serial.write(RL_click); |
Najib_irvani | 46:85169ae8659b | 93 | Serial.write(aR2); |
Najib_irvani | 46:85169ae8659b | 94 | Serial.write(aL2); |
Najib_irvani | 46:85169ae8659b | 95 | Serial.write(RX); |
Najib_irvani | 46:85169ae8659b | 96 | Serial.write(RY); |
Najib_irvani | 46:85169ae8659b | 97 | Serial.write(LX); |
Najib_irvani | 46:85169ae8659b | 98 | Serial.write(LY); |
Najib_irvani | 46:85169ae8659b | 99 | |
Najib_irvani | 46:85169ae8659b | 100 | // Debug |
Najib_irvani | 46:85169ae8659b | 101 | |
Najib_irvani | 46:85169ae8659b | 102 | /* |
Najib_irvani | 46:85169ae8659b | 103 | Serial.print(millis()); |
Najib_irvani | 46:85169ae8659b | 104 | Serial.print("\t"); |
Najib_irvani | 46:85169ae8659b | 105 | Serial.print(button); |
Najib_irvani | 46:85169ae8659b | 106 | Serial.print("\t"); |
Najib_irvani | 46:85169ae8659b | 107 | Serial.print(RL); |
Najib_irvani | 46:85169ae8659b | 108 | Serial.print("\t"); |
Najib_irvani | 46:85169ae8659b | 109 | Serial.print(button_click); |
Najib_irvani | 46:85169ae8659b | 110 | Serial.print("\t"); |
Najib_irvani | 46:85169ae8659b | 111 | Serial.print(RL_click); |
Najib_irvani | 46:85169ae8659b | 112 | Serial.print("\t"); |
Najib_irvani | 46:85169ae8659b | 113 | Serial.print(aR2); |
Najib_irvani | 46:85169ae8659b | 114 | Serial.print("\t"); |
Najib_irvani | 46:85169ae8659b | 115 | Serial.print(aL2); |
Najib_irvani | 46:85169ae8659b | 116 | Serial.print("\t"); |
Najib_irvani | 46:85169ae8659b | 117 | Serial.print(RX); |
Najib_irvani | 46:85169ae8659b | 118 | Serial.print("\t"); |
Najib_irvani | 46:85169ae8659b | 119 | Serial.print(RY); |
Najib_irvani | 46:85169ae8659b | 120 | Serial.print("\t"); |
Najib_irvani | 46:85169ae8659b | 121 | Serial.print(LX); |
Najib_irvani | 46:85169ae8659b | 122 | Serial.print("\t"); |
Najib_irvani | 46:85169ae8659b | 123 | Serial.println(LY); |
Najib_irvani | 46:85169ae8659b | 124 | */ |
Najib_irvani | 46:85169ae8659b | 125 | } |
Najib_irvani | 46:85169ae8659b | 126 | |
Najib_irvani | 46:85169ae8659b | 127 | /*****************************************************************************************/ |
Najib_irvani | 46:85169ae8659b | 128 | /** SETUP REGISTER dan INISIALISASI **/ |
Najib_irvani | 46:85169ae8659b | 129 | /** - Setup Joystik **/ |
Najib_irvani | 46:85169ae8659b | 130 | /** - Baud Rate Serial 115200, 8-bit, 1 stop, 0 parity **/ |
Najib_irvani | 46:85169ae8659b | 131 | /*****************************************************************************************/ |
Najib_irvani | 46:85169ae8659b | 132 | |
Najib_irvani | 46:85169ae8659b | 133 | void setup() { |
Najib_irvani | 46:85169ae8659b | 134 | Serial.begin(115200); |
Najib_irvani | 46:85169ae8659b | 135 | |
Najib_irvani | 46:85169ae8659b | 136 | setup_joystik(); |
Najib_irvani | 46:85169ae8659b | 137 | } |
Najib_irvani | 46:85169ae8659b | 138 | |
Najib_irvani | 46:85169ae8659b | 139 | |
Najib_irvani | 46:85169ae8659b | 140 | /*****************************************************************************************/ |
Najib_irvani | 46:85169ae8659b | 141 | /** **/ |
Najib_irvani | 46:85169ae8659b | 142 | /** FUNGSI PEMBACAAN DATA JOYSTIK **/ |
Najib_irvani | 46:85169ae8659b | 143 | /** - Data dari Joystik dikirim melalui Bluetooth. **/ |
Najib_irvani | 46:85169ae8659b | 144 | /** Lihat Library "PS3BT.h" **/ |
Najib_irvani | 46:85169ae8659b | 145 | /** - Data tombol dari joystik adalah data 1-bit. Pengiriman data melalui USART **/ |
Najib_irvani | 46:85169ae8659b | 146 | /** adalah 8-bit. Agar pengiriman data efisien, maka data 1-bit digabungkan **/ |
Najib_irvani | 46:85169ae8659b | 147 | /** agar terbentuk data 8-bit **/ |
Najib_irvani | 46:85169ae8659b | 148 | /** - Penggabungan data segitiga, longkaran, silang, kotak, arah atas, arah kanan, **/ |
Najib_irvani | 46:85169ae8659b | 149 | /** arah bawah, arah kiri disimpan dalam variabel "button" **/ |
Najib_irvani | 46:85169ae8659b | 150 | /** - Urutan data pada variabel "button" dan "button_click" **/ |
Najib_irvani | 46:85169ae8659b | 151 | /** adalah sebagai berikut **/ |
Najib_irvani | 46:85169ae8659b | 152 | /** **/ |
Najib_irvani | 46:85169ae8659b | 153 | /** |------|-------|-------|------|-------|--------|-----------|----------| **/ |
Najib_irvani | 46:85169ae8659b | 154 | /** Bit Ke | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | **/ |
Najib_irvani | 46:85169ae8659b | 155 | /** |------|-------|-------|------|-------|--------|-----------|----------| **/ |
Najib_irvani | 46:85169ae8659b | 156 | /** Data | kiri | bawah | kanan | atas | kotak | silang | lingkaran | segitiga | **/ |
Najib_irvani | 46:85169ae8659b | 157 | /** |------|-------|-------|------|-------|--------|-----------|----------| **/ |
Najib_irvani | 46:85169ae8659b | 158 | /** **/ |
Najib_irvani | 46:85169ae8659b | 159 | /** - Penggabungan data R1, R2, L1, L2, R3, L3, START, dan SELECT disimpan dalam **/ |
Najib_irvani | 46:85169ae8659b | 160 | /** variabel "RL" **/ |
Najib_irvani | 46:85169ae8659b | 161 | /** - Urutan data pada variabel "RL" dan "RL_click" adalah **/ |
Najib_irvani | 46:85169ae8659b | 162 | /** sebagai berikut **/ |
Najib_irvani | 46:85169ae8659b | 163 | /** **/ |
Najib_irvani | 46:85169ae8659b | 164 | /** |----|--------|-------|----|----|----|----| **/ |
Najib_irvani | 46:85169ae8659b | 165 | /** Bit Ke | 6 | 5 | 4 | 3 | 2 | 1 | 0 | **/ |
Najib_irvani | 46:85169ae8659b | 166 | /** |----|--------|-------|----|----|----|----| **/ |
Najib_irvani | 46:85169ae8659b | 167 | /** Data | PS | SELECT | START | L3 | L1 | R3 | R1 | **/ |
Najib_irvani | 46:85169ae8659b | 168 | /** |----|--------|-------|----|----|----|----| **/ |
Najib_irvani | 46:85169ae8659b | 169 | /** **/ |
Najib_irvani | 46:85169ae8659b | 170 | /*****************************************************************************************/ |
Najib_irvani | 46:85169ae8659b | 171 | |
Najib_irvani | 46:85169ae8659b | 172 | void loop() { |
Najib_irvani | 46:85169ae8659b | 173 | button = 0; |
Najib_irvani | 46:85169ae8659b | 174 | RL = 0; |
Najib_irvani | 46:85169ae8659b | 175 | button_click=0; |
Najib_irvani | 46:85169ae8659b | 176 | RL_click=0; |
Najib_irvani | 46:85169ae8659b | 177 | Usb.Task(); |
Najib_irvani | 46:85169ae8659b | 178 | |
Najib_irvani | 46:85169ae8659b | 179 | // Pembacaan data joystik dilakukan jika PS3 tersambung ke Arduino |
Najib_irvani | 46:85169ae8659b | 180 | if (PS3.PS3Connected || PS3.PS3NavigationConnected) { |
Najib_irvani | 46:85169ae8659b | 181 | // Pembacaan dan penggabungan data segitiga, lingkaran, silang, kotak, atas, kanan, bawah, kiri |
Najib_irvani | 46:85169ae8659b | 182 | // Data bernilai '1' jika tombol ditekan |
Najib_irvani | 46:85169ae8659b | 183 | if(PS3.getButtonPress(TRIANGLE)){ |
Najib_irvani | 46:85169ae8659b | 184 | button = button + (0x1 << 0); |
Najib_irvani | 46:85169ae8659b | 185 | } |
Najib_irvani | 46:85169ae8659b | 186 | if(PS3.getButtonPress(CIRCLE)){ |
Najib_irvani | 46:85169ae8659b | 187 | button = button + (0x1 << 1); |
Najib_irvani | 46:85169ae8659b | 188 | } |
Najib_irvani | 46:85169ae8659b | 189 | if(PS3.getButtonPress(CROSS)){ |
Najib_irvani | 46:85169ae8659b | 190 | button = button + (0x1 << 2); |
Najib_irvani | 46:85169ae8659b | 191 | } |
Najib_irvani | 46:85169ae8659b | 192 | if(PS3.getButtonPress(SQUARE)){ |
Najib_irvani | 46:85169ae8659b | 193 | button = button + (0x1 << 3); |
Najib_irvani | 46:85169ae8659b | 194 | } |
Najib_irvani | 46:85169ae8659b | 195 | if(PS3.getButtonPress(UP)){ |
Najib_irvani | 46:85169ae8659b | 196 | button = button + (0x1 << 4); |
Najib_irvani | 46:85169ae8659b | 197 | } |
Najib_irvani | 46:85169ae8659b | 198 | if(PS3.getButtonPress(RIGHT)){ |
Najib_irvani | 46:85169ae8659b | 199 | button = button + (0x1 << 5); |
Najib_irvani | 46:85169ae8659b | 200 | } |
Najib_irvani | 46:85169ae8659b | 201 | if(PS3.getButtonPress(DOWN)){ |
Najib_irvani | 46:85169ae8659b | 202 | button = button + (0x1 << 6); |
Najib_irvani | 46:85169ae8659b | 203 | } |
Najib_irvani | 46:85169ae8659b | 204 | if(PS3.getButtonPress(LEFT)){ |
Najib_irvani | 46:85169ae8659b | 205 | button = button + (0x1 << 7); |
Najib_irvani | 46:85169ae8659b | 206 | } |
Najib_irvani | 46:85169ae8659b | 207 | |
Najib_irvani | 46:85169ae8659b | 208 | // Pembacaan dan penggabungan data R1, R3, L1, L3, START, SELECT, dan PS |
Najib_irvani | 46:85169ae8659b | 209 | // Data bernilai '1' jika tombol ditekan |
Najib_irvani | 46:85169ae8659b | 210 | if(PS3.getButtonPress(R1)){ |
Najib_irvani | 46:85169ae8659b | 211 | RL = RL + (0x1 << 0); |
Najib_irvani | 46:85169ae8659b | 212 | } |
Najib_irvani | 46:85169ae8659b | 213 | if(PS3.getButtonPress(R3)){ |
Najib_irvani | 46:85169ae8659b | 214 | RL = RL + (0x1 << 1); |
Najib_irvani | 46:85169ae8659b | 215 | } |
Najib_irvani | 46:85169ae8659b | 216 | if(PS3.getButtonPress(L1)){ |
Najib_irvani | 46:85169ae8659b | 217 | RL = RL + (0x1 << 2); |
Najib_irvani | 46:85169ae8659b | 218 | } |
Najib_irvani | 46:85169ae8659b | 219 | if(PS3.getButtonPress(L3)){ |
Najib_irvani | 46:85169ae8659b | 220 | RL = RL + (0x1 << 3); |
Najib_irvani | 46:85169ae8659b | 221 | } |
Najib_irvani | 46:85169ae8659b | 222 | if(PS3.getButtonPress(START)){ |
Najib_irvani | 46:85169ae8659b | 223 | RL = RL + (0x1 << 4); |
Najib_irvani | 46:85169ae8659b | 224 | } |
Najib_irvani | 46:85169ae8659b | 225 | if(PS3.getButtonPress(SELECT)){ |
Najib_irvani | 46:85169ae8659b | 226 | RL = RL + (0x1 << 5); |
Najib_irvani | 46:85169ae8659b | 227 | } |
Najib_irvani | 46:85169ae8659b | 228 | if(PS3.getButtonPress(PS)){ |
Najib_irvani | 46:85169ae8659b | 229 | RL = RL + (0x1 << 6); |
Najib_irvani | 46:85169ae8659b | 230 | } |
Najib_irvani | 46:85169ae8659b | 231 | |
Najib_irvani | 46:85169ae8659b | 232 | // Pembacaan dan penggabungan data segitiga, lingkaran, silang, kotak, atas, kanan, bawah, kiri |
Najib_irvani | 46:85169ae8659b | 233 | // Data bernilai '1' hanya saat tombol pertama kali ditekan |
Najib_irvani | 46:85169ae8659b | 234 | if(PS3.getButtonClick(TRIANGLE)){ |
Najib_irvani | 46:85169ae8659b | 235 | button_click = button_click + (0x1 << 0); |
Najib_irvani | 46:85169ae8659b | 236 | } |
Najib_irvani | 46:85169ae8659b | 237 | if(PS3.getButtonClick(CIRCLE)){ |
Najib_irvani | 46:85169ae8659b | 238 | button_click = button_click + (0x1 << 1); |
Najib_irvani | 46:85169ae8659b | 239 | } |
Najib_irvani | 46:85169ae8659b | 240 | if(PS3.getButtonClick(CROSS)){ |
Najib_irvani | 46:85169ae8659b | 241 | button_click = button_click + (0x1 << 2); |
Najib_irvani | 46:85169ae8659b | 242 | } |
Najib_irvani | 46:85169ae8659b | 243 | if(PS3.getButtonClick(SQUARE)){ |
Najib_irvani | 46:85169ae8659b | 244 | button_click = button_click + (0x1 << 3); |
Najib_irvani | 46:85169ae8659b | 245 | } |
Najib_irvani | 46:85169ae8659b | 246 | if(PS3.getButtonClick(UP)){ |
Najib_irvani | 46:85169ae8659b | 247 | button_click = button_click + (0x1 << 4); |
Najib_irvani | 46:85169ae8659b | 248 | } |
Najib_irvani | 46:85169ae8659b | 249 | if(PS3.getButtonClick(RIGHT)){ |
Najib_irvani | 46:85169ae8659b | 250 | button_click = button_click + (0x1 << 5); |
Najib_irvani | 46:85169ae8659b | 251 | } |
Najib_irvani | 46:85169ae8659b | 252 | if(PS3.getButtonClick(DOWN)){ |
Najib_irvani | 46:85169ae8659b | 253 | button_click = button_click + (0x1 << 6); |
Najib_irvani | 46:85169ae8659b | 254 | } |
Najib_irvani | 46:85169ae8659b | 255 | if(PS3.getButtonClick(LEFT)){ |
Najib_irvani | 46:85169ae8659b | 256 | button_click = button_click + (0x1 << 7); |
Najib_irvani | 46:85169ae8659b | 257 | } |
Najib_irvani | 46:85169ae8659b | 258 | |
Najib_irvani | 46:85169ae8659b | 259 | if(PS3.getButtonClick(R1)){ |
Najib_irvani | 46:85169ae8659b | 260 | RL_click = RL_click + (0x1 << 0); |
Najib_irvani | 46:85169ae8659b | 261 | } |
Najib_irvani | 46:85169ae8659b | 262 | if(PS3.getButtonClick(R3)){ |
Najib_irvani | 46:85169ae8659b | 263 | RL_click = RL_click + (0x1 << 1); |
Najib_irvani | 46:85169ae8659b | 264 | } |
Najib_irvani | 46:85169ae8659b | 265 | if(PS3.getButtonClick(L1)){ |
Najib_irvani | 46:85169ae8659b | 266 | RL_click = RL_click + (0x1 << 2); |
Najib_irvani | 46:85169ae8659b | 267 | } |
Najib_irvani | 46:85169ae8659b | 268 | if(PS3.getButtonClick(L3)){ |
Najib_irvani | 46:85169ae8659b | 269 | RL_click = RL_click + (0x1 << 3); |
Najib_irvani | 46:85169ae8659b | 270 | } |
Najib_irvani | 46:85169ae8659b | 271 | if(PS3.getButtonClick(START)){ |
Najib_irvani | 46:85169ae8659b | 272 | RL_click = RL_click + (0x1 << 4); |
Najib_irvani | 46:85169ae8659b | 273 | } |
Najib_irvani | 46:85169ae8659b | 274 | if(PS3.getButtonClick(SELECT)){ |
Najib_irvani | 46:85169ae8659b | 275 | RL_click = RL_click + (0x1 << 5); |
Najib_irvani | 46:85169ae8659b | 276 | } |
Najib_irvani | 46:85169ae8659b | 277 | if(PS3.getButtonClick(PS)){ |
Najib_irvani | 46:85169ae8659b | 278 | RL_click = RL_click + (0x1 << 6); |
Najib_irvani | 46:85169ae8659b | 279 | } |
Najib_irvani | 46:85169ae8659b | 280 | |
Najib_irvani | 46:85169ae8659b | 281 | // Tombol Analog |
Najib_irvani | 46:85169ae8659b | 282 | LX = PS3.getAnalogHat(LeftHatX); |
Najib_irvani | 46:85169ae8659b | 283 | LY = PS3.getAnalogHat(LeftHatY); |
Najib_irvani | 46:85169ae8659b | 284 | RX = PS3.getAnalogHat(RightHatX); |
Najib_irvani | 46:85169ae8659b | 285 | RY = PS3.getAnalogHat(RightHatY); |
Najib_irvani | 46:85169ae8659b | 286 | |
Najib_irvani | 46:85169ae8659b | 287 | aL2 = PS3.getAnalogButton(L2); |
Najib_irvani | 46:85169ae8659b | 288 | aR2 = PS3.getAnalogButton(R2); |
Najib_irvani | 46:85169ae8659b | 289 | |
Najib_irvani | 46:85169ae8659b | 290 | kirimdatajoystik(); |
Najib_irvani | 46:85169ae8659b | 291 | } else { |
Najib_irvani | 46:85169ae8659b | 292 | // PS3 Disconnected |
Najib_irvani | 46:85169ae8659b | 293 | Serial.write(0x88); |
Najib_irvani | 46:85169ae8659b | 294 | Serial.write(0x09); |
Najib_irvani | 46:85169ae8659b | 295 | } |
Najib_irvani | 46:85169ae8659b | 296 | delay(3); |
Najib_irvani | 46:85169ae8659b | 297 | } |
Najib_irvani | 46:85169ae8659b | 298 | |
Najib_irvani | 46:85169ae8659b | 299 |