Open esportsim opened 3 years ago
Hi, my simple code stops if I remove the USB from the PC. Why?
unsigned long previousMillis = 0; unsigned long currentMillis;
unsigned long serialCurrentMillis; unsigned long serialPreviousMillis; boolean is_working_led_on = true; int led_interval = 200; int working_led = 3;
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_GAMEPAD, 128, 0, true, true, false, false, false, false, false, false, false, false, false);
void setup() { pinMode(working_led, OUTPUT); Joystick.begin(); }
void loop() {
// WORKING LED ---------------------------------------------------------------- currentMillis = millis();
if (currentMillis - previousMillis >= led_interval) { previousMillis = currentMillis; if (is_working_led_on) { digitalWrite(working_led, LOW); is_working_led_on = false; } else { digitalWrite(working_led, HIGH); is_working_led_on = true; } }
Joystick.setButton(0, 1); Joystick.setButton(1, 1);
}
Probably because the sketch doesn't receive a response from the computer to the Joystick.setButton statements.
Hi, my simple code stops if I remove the USB from the PC. Why?
include
unsigned long previousMillis = 0; unsigned long currentMillis;
unsigned long serialCurrentMillis; unsigned long serialPreviousMillis; boolean is_working_led_on = true; int led_interval = 200; int working_led = 3;
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_GAMEPAD, 128, 0, true, true, false, false, false, false, false, false, false, false, false);
void setup() { pinMode(working_led, OUTPUT); Joystick.begin(); }
void loop() {
// WORKING LED ---------------------------------------------------------------- currentMillis = millis();
if (currentMillis - previousMillis >= led_interval) { previousMillis = currentMillis; if (is_working_led_on) { digitalWrite(working_led, LOW); is_working_led_on = false; } else { digitalWrite(working_led, HIGH); is_working_led_on = true; } }
}