if(error == 0){
Serial.print("Found Controller, configured successful ");
Serial.print("pressures = ");
if (pressures)
Serial.println("true ");
else
Serial.println("false");
Serial.print("rumble = ");
if (rumble)
Serial.println("true)");
else
Serial.println("false");
Serial.println("Try out all the buttons, X will vibrate the controller, faster as you press harder;");
Serial.println("holding L1 or R1 will print out the analog stick values.");
Serial.println("Note: Go to www.billporter.info for updates and to report bugs.");
}
else if(error == 1)
Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips");
else if(error == 2)
Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips");
else if(error == 3)
Serial.println("Controller refusing to enter Pressures mode, may not support it. ");
type = ps2x.readType();
switch(type) {
case 0:
Serial.print("Unknown Controller type found ");
break;
case 1:
Serial.print("DualShock Controller found ");
break;
case 2:
Serial.print("GuitarHero Controller found ");
break;
case 3:
Serial.print("Wireless Sony DualShock Controller found ");
break;
}
}
void loop() {
// put your main code here, to run repeatedly:
if(error == 1) //skip loop if no controller found
return;
if(type == 2){
ps2x.read_gamepad();
}
else
{
ps2x.read_gamepad(false, vibrate);
vibrate = ps2x.Analog(PSAB_CROSS);
if (ps2x.NewButtonState())
{
if(ps2x.Button(PSB_L1))
{
digitalWrite(relay, LOW);
}
else
{
digitalWrite(relay, HIGH);
}
}
}
}
Sản phẩm liên quan
Đồng hồ thời gian, nhiệt độ, độ ẩm siêu mỏng
Hàng còn 1 cái
Đồng hồ thời gian, nhiệt độ, độ ẩm HTC-1
Hàng còn 31 cái
Đồng hồ điện tử để bàn LCD - Thời Gian, Lịch, Báo Thức, Nhiệt Độ (Có đèn)
Hàng còn 7 cái
Đèn led USB siêu sáng 24 bóng 5V 12W
Hàng còn 5 cái
Que đo nhiệt độ dùng pin TP101
Hàng còn 28 cái
Tay cầm game cho Raspberry Pi, PC Windows Mac
Hàng còn 1 cái
Đầu đọc thẻ nhớ MicroSD
Hàng còn 137 cái
Tay cầm Sony PS2 có dây
Hàng còn 8 cái
USB Bluetooth Audio (Tích hợp pin) - Loại tốt
Hàng còn 7 cái
Máy Phun Sương Tạo Độ Ẩm Mini Để Bàn Sạc USB
Hàng còn 1 cái
Tay cầm Sony PS2 không dây (Kèm adapter giao tiếp SPI cho Arduino)