Help my code is not doing what I told it to do (ACNH auto nook mile collector)

I am trying to make a ACNH auto nook mile collector. I wrote the code for my Leonardo to control my switch automatically to earn nook miles by running to the terminal collect my 7+500 nook mile reword but my Arduino is not running the code how I wrote it. can any butty tell me what im doing wrong.

#include "SwitchJoystick.h"

// Create pro_controller
SwitchJoystick_ pro_controller;

uint32_t timer = 0;
int num = 0;

// Set to true to test "Auto Send" mode or false to test "Manual Send" mode.

void setup() {
pro_controller.begin();// Set to null to test "Auto Send" mode or false to test "Manual Send" mode.
pro_controller.setXAxis(128);
pro_controller.setYAxis(128);
pro_controller.setZAxis(128);
pro_controller.setRzAxis(128);
pro_controller.releaseButton(0); // Y
pro_controller.releaseButton(1); // B
pro_controller.releaseButton(2); // A
pro_controller.releaseButton(3); // X
pro_controller.releaseButton(4); // L
pro_controller.releaseButton(5); // R
pro_controller.releaseButton(6); // Zl
pro_controller.releaseButton(7); // Zr
pro_controller.releaseButton(8); // -
pro_controller.releaseButton(9); // +
pro_controller.releaseButton(10); // Lstick
pro_controller.releaseButton(11); // Rstick
pro_controller.releaseButton(12); // Home
pro_controller.releaseButton(13); // capture
pro_controller.setHatSwitch(-1); // RELEASE
pro_controller.sendState();
}

void loop() {
if (millis() > timer) {
timer = millis() + 10; // 10 ms = 1/0.010 == 100Hz
if(num==0){
pro_controller.pressButton(4); // L
pro_controller.pressButton(5); // R
pro_controller.releaseButton(4); // L
pro_controller.releaseButton(5); // R
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
}
pro_controller.pressButton(8); // -
pro_controller.releaseButton(8); // -
delay(1990);
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(1500);
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(13000);
pro_controller.pressButton(12); // Home
pro_controller.releaseButton(12); // Home
delay(1300);
pro_controller.pressButton(3); // X
pro_controller.releaseButton(3); // X
delay(860);
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(3650);
pro_controller.setHatSwitch(180); // DOWN
pro_controller.setHatSwitch(-1); // RELEASE
for(int i=0; i<5;i++){
pro_controller.setHatSwitch(90); // RIGHT
pro_controller.setHatSwitch(-1); // RELEASE
}
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(1630);
for(int i=0; i<15;i++){
pro_controller.setHatSwitch(180); // DOWN
pro_controller.setHatSwitch(-1); // RELEASE
}
pro_controller.setHatSwitch(90); // RIGHT
pro_controller.setHatSwitch(-1); // RELEASE
for(int i=0; i<7;i++){
pro_controller.setHatSwitch(180); // DOWN
pro_controller.setHatSwitch(-1); // RELEASE
}
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
for(int i=0; i<2;i++){
pro_controller.setHatSwitch(180); // DOWN
pro_controller.setHatSwitch(-1); // RELEASE
}
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
for(int i=0; i<2;i++){
pro_controller.setHatSwitch(90); // RIGHT
pro_controller.setHatSwitch(-1); // RELEASE
}
if(num==0){
for(int i=0; i<60;i++){
pro_controller.setHatSwitch(0); // UP
pro_controller.setHatSwitch(-1); // RELEASE
num++;
}
}else{
pro_controller.setHatSwitch(180); // DOWN
pro_controller.setHatSwitch(-1); // RELEASE
}
for(int i=0; i<4;i++){
pro_controller.setHatSwitch(90); // RIGHT
pro_controller.setHatSwitch(-1); // RELEASE
}
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
pro_controller.pressButton(12); // Home
pro_controller.releaseButton(12); // Home
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
for(int i = 0;i<8;i++){
pro_controller.setHatSwitch(270); // LEFT
pro_controller.setHatSwitch(-1); // RELEASE
}
pro_controller.setHatSwitch(90); // RIGHT
pro_controller.setHatSwitch(-1); // RELEASE
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(50560);
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
pro_controller.pressButton(1); // B
for(int i=0;i<100;i++){
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
}
pro_controller.releaseButton(1); // B
pro_controller.setXAxis(255); // Left pro_controller RIGHT
delay(4920);
pro_controller.setXAxis(128); // Release
pro_controller.setYAxis(0); // Left pro_controller UP
delay(1710);
pro_controller.setYAxis(128); // Release
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
pro_controller.setYAxis(0); // Left pro_controller UP
delay(500);
pro_controller.setYAxis(128); // Release
pro_controller.setXAxis(255); // Left pro_controller RIGHT
delay(1630);
pro_controller.setXAxis(128); //
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(3120);
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(2530);
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(1420);
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(3310);
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(2880);
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(6380);
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(2830);
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(2250);
pro_controller.pressButton(2); // A
pro_controller.releaseButton(2); // A
delay(1050);
pro_controller.pressButton(1); // B
pro_controller.releaseButton(1); // B
pro_controller.pressButton(1); // B
pro_controller.releaseButton(1); // B
pro_controller.pressButton(1); // B
pro_controller.releaseButton(1); // B
pro_controller.pressButton(1); // B
pro_controller.releaseButton(1); // B
pro_controller.pressButton(1); // B
pro_controller.releaseButton(1); // B
pro_controller.sendState();
}
}

If you tested the program as you wrote it, at what point did it stop working as you wanted?
OR did you wait until you had composed the entire volume before testing?
Paul

Hi, @hugulokvufoikjk
Welcome to the forum.
To add code please click this link;

Before reposting it, hit CTRL-T in the IDE to Auto format your code to make it easier to read.

Sorry what is that?

Can you please post a copy of your circuit?

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

Do you not also need SwitchJoystick.c ?

do you realize that "delay(1300)" suspends the program from executing for 1.3 seconds.
and delay(13000) suspends the program for 13 seconds?

Oh and by the way, your code is doing what you "told" it to do. The problem is you want it to do something other than what you told it to.

Hi @hugulokvufoikjk

I don't agree with this statement.
I'm sure the arduino is running the code you wrote for it.

The statement should be:
I can't write a code for the arduino to do what I want.

BTW put your code between tags.

RV mineirin

So your very first task is to explain what that means.

The likelihood of anyone looking at your posting, knowing what that means - to you at least - is frankly, not all that great. However if you explain what it is, various people may well become interested. :grin:

it terns out I needed to delay button presses and releases. my code was runing faster the my switch could read them my code is working now thanks for giving me the idea to add delays to my code. thank you for your time.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.