#include <PS2X_lib.h> PS2X ps2x; int error = 0; byte type = 0; int vibrate = 0; void setup() { error = ps2x.config_gamepad(13,11,10,12, true, true); type = ps2x.readType(); } void loop() { ps2x.read_gamepad(false, vibrate); if(ps2x.Button(PSB_PAD_UP)) { pinMode(A0, OUTPUT); digitalWrite(A0, 1); } ps2x.read_gamepad(false, vibrate); if(ps2x.Button(PSB_PAD_DOWN)) { pinMode(A0, OUTPUT); digitalWrite(A0, 0); } delay(50); }
Открыть пример: Online ArduBlock
#include <PS2X_lib.h> PS2X ps2x; int error = 0; byte type = 0; int vibrate = 0; int x = 0; void setup() { error = ps2x.config_gamepad(13,11,10,12, true, true); type = ps2x.readType(); } void loop() { ps2x.read_gamepad(false, vibrate); if(ps2x.Button(PSB_PAD_UP)) { x = 1; } if (x == 1) { pinMode(A0, OUTPUT); digitalWrite(A0, 1); } else { pinMode(A0, OUTPUT); digitalWrite(A0, 0); } ps2x.read_gamepad(false, vibrate); if(ps2x.Button(PSB_GREEN)) { x = 2; } if (x == 2) { pinMode(A1, OUTPUT); digitalWrite(A1, 1); } else { pinMode(A1, OUTPUT); digitalWrite(A1, 0); } x = 0; delay(50); }
Открыть пример: Online ArduBlock
Видеоурок: