void loop(){
static uint32_t previousMillis;
uint32_t currentMillis = millis();
const uint32_t interval = 1000;
static int state; //used to indicate state 0 or state 1
// States
// 0 = wait for next state
// 1 = do action 1
// 2 = wait for next state
// 3 = do action 2 & set state to 0
void loop(){
static uint32_t previousMillis;
uint32_t currentMillis = millis();
const uint32_t interval = 1000;
static int state; //used to indicate state 0 or state 1
// States
// 0 = wait for next state
// 1 = do action 1
// 2 = wait for next state
// 3 = do action 2 & set state to 0
I can't seem to make this work. As soon as I call something for the mouse it quits working. Do you have a recommendation?
`#include
USBHID HID;
//USBMultiXBox360<4> x360;
void setup(){ USBComposite.clear(); Mouse.registerComponent(); //x360.registerComponent(); USBComposite.begin(); USBComposite.setProductId(0x0031); Mouse.begin(); while (!USBComposite); }
void loop(){ static uint32_t previousMillis; uint32_t currentMillis = millis(); const uint32_t interval = 1000; static int state; //used to indicate state 0 or state 1 // States // 0 = wait for next state // 1 = do action 1 // 2 = wait for next state // 3 = do action 2 & set state to 0
if (currentMillis - previousMillis >= interval) { previousMillis = currentMillis; state++; }
if (state == 1) { //x360.controllers[0].X(32767); //x360.controllers[1].Y(32767); //x360.controllers[2].XRight(32767); //x360.controllers[3].YRight(32767); Mouse.move(20,0); state = 2; }
if (state == 3) { //x360.controllers[0].X(-32768); //x360.controllers[1].Y(-32768); //x360.controllers[2].XRight(-32768); //x360.controllers[3].YRight(-32768); Mouse.move(-20,0); state = 0; }
}#include
USBHID HID;
//USBMultiXBox360<4> x360;
void setup(){ USBComposite.clear(); Mouse.registerComponent(); //x360.registerComponent(); USBComposite.begin(); USBComposite.setProductId(0x0031); Mouse.begin(); while (!USBComposite); }
void loop(){ static uint32_t previousMillis; uint32_t currentMillis = millis(); const uint32_t interval = 1000; static int state; //used to indicate state 0 or state 1 // States // 0 = wait for next state // 1 = do action 1 // 2 = wait for next state // 3 = do action 2 & set state to 0
if (currentMillis - previousMillis >= interval) { previousMillis = currentMillis; state++; }
if (state == 1) { //x360.controllers[0].X(32767); //x360.controllers[1].Y(32767); //x360.controllers[2].XRight(32767); //x360.controllers[3].YRight(32767); Mouse.move(20,0); state = 2; }
if (state == 3) { //x360.controllers[0].X(-32768); //x360.controllers[1].Y(-32768); //x360.controllers[2].XRight(-32768); //x360.controllers[3].YRight(-32768); Mouse.move(-20,0); state = 0; }
}l`