Update 18 Februari 2017, PID laucnher dan Base sudah diperbarui
Dependencies: Motor PID Joystick_OrdoV5 mbed millis
Fork of MainProgram_BaseBaru_otomatis-reloader by
Diff: PS3Arduino.txt
- Revision:
- 12:e07c59c28c29
- Parent:
- 2:ac21a024ac80
diff -r e1efcc958f4b -r e07c59c28c29 PS3Arduino.txt --- a/PS3Arduino.txt Tue Nov 29 15:26:09 2016 +0000 +++ b/PS3Arduino.txt Sat Dec 03 05:43:10 2016 +0000 @@ -9,7 +9,7 @@ /** **/ /** Last Update : 01 Februar1 2015, 20.30 **/ /*********************************************************************************************/ - + #include <PS3BT.h> #include <usbhub.h> //#include <PS3USB.h> @@ -18,10 +18,10 @@ #ifdef dobogusinclude #include <spi4teensy3.h> #endif - - + + USB Usb; - + // Bluetooth // You can create the instance of the class in two ways BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so @@ -34,25 +34,25 @@ PS3USB PS3(&Usb); // This will just create the instance //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 */ - + boolean printAngle; uint8_t state = 0; - + // Deklarasi tombol boolean kiri_click=0, kanan_click=0, atas_click=0, bawah_click=0; boolean segitiga_click=0, lingkaran_click=0, kotak_click=0, silang_click=0; boolean L1_click=0, R1_click=0, L3_click=0, R3_click=0; boolean START_click=0, SELECT_click=0, PS_click=0; - + // Deklarasi variabel tombol analog unsigned char LX, LY, RX, RY, aL2, aR2; - + // Deklarasi varibel data yang dikirim unsigned char button; unsigned char RL; unsigned int button_click; unsigned int RL_click; - + void setup_joystik() { while (!Serial) // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection @@ -70,7 +70,7 @@ } //Serial.print(F("\r\nPS3 USB Library Started")); } - + /*********************************************************************************************/ /** **/ /** FUNGSI PENGIRIMAN DATA **/ @@ -80,7 +80,7 @@ /** |------|------|--------|----|--------------|----------|----|----|----|----|----|----| **/ /** **/ /*********************************************************************************************/ - + void kirimdatajoystik() { @@ -96,9 +96,9 @@ Serial.write(RY); Serial.write(LX); Serial.write(LY); - + // Debug - + /* Serial.print(millis()); Serial.print("\t"); @@ -123,20 +123,20 @@ Serial.println(LY); */ } - + /*****************************************************************************************/ /** SETUP REGISTER dan INISIALISASI **/ /** - Setup Joystik **/ /** - Baud Rate Serial 115200, 8-bit, 1 stop, 0 parity **/ /*****************************************************************************************/ - + void setup() { Serial.begin(115200); - + setup_joystik(); } - - + + /*****************************************************************************************/ /** **/ /** FUNGSI PEMBACAAN DATA JOYSTIK **/ @@ -168,14 +168,14 @@ /** |----|--------|-------|----|----|----|----| **/ /** **/ /*****************************************************************************************/ - + void loop() { button = 0; RL = 0; button_click=0; RL_click=0; Usb.Task(); - + // Pembacaan data joystik dilakukan jika PS3 tersambung ke Arduino if (PS3.PS3Connected || PS3.PS3NavigationConnected) { // Pembacaan dan penggabungan data segitiga, lingkaran, silang, kotak, atas, kanan, bawah, kiri @@ -204,7 +204,7 @@ if(PS3.getButtonPress(LEFT)){ button = button + (0x1 << 7); } - + // Pembacaan dan penggabungan data R1, R3, L1, L3, START, SELECT, dan PS // Data bernilai '1' jika tombol ditekan if(PS3.getButtonPress(R1)){ @@ -228,7 +228,7 @@ if(PS3.getButtonPress(PS)){ RL = RL + (0x1 << 6); } - + // Pembacaan dan penggabungan data segitiga, lingkaran, silang, kotak, atas, kanan, bawah, kiri // Data bernilai '1' hanya saat tombol pertama kali ditekan if(PS3.getButtonClick(TRIANGLE)){ @@ -255,7 +255,7 @@ if(PS3.getButtonClick(LEFT)){ button_click = button_click + (0x1 << 7); } - + if(PS3.getButtonClick(R1)){ RL_click = RL_click + (0x1 << 0); } @@ -277,7 +277,7 @@ if(PS3.getButtonClick(PS)){ RL_click = RL_click + (0x1 << 6); } - + // Tombol Analog LX = PS3.getAnalogHat(LeftHatX); LY = PS3.getAnalogHat(LeftHatY); @@ -295,3 +295,5 @@ } delay(3); } + + \ No newline at end of file