Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Weird behavior using code that works on Arduino Uno on Trink
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Weird behavior using code that works on Arduino Uno on Trink

by ltpitt on Fri Jun 26, 2020 4:08 pm

Hi all!

I am building a small mod that will allow me to reset my Nintendo 64 without leaving the sofa (I know, I am a horrible person :D).

I didn't have a Trinket Pro in my drawer so I started writing and testing the code on an Arduino Uno, here's the final working version:
Code: Select all | TOGGLE FULL SIZE
#include <N64Controller.h> // https://github.com/pothos/arduino-n64-controller-library also available in Arduino IDE

const int N64ControllerPin =  12;
const int relayPin =  8;
N64Controller player1 (N64ControllerPin);

void setup() {
    pinMode(relayPin, OUTPUT);
    player1.begin();
}

void loop() {
    delay(30);
    player1.update();
    if (player1.Z() && player1.R() && player1.A() && player1.B() && player1.Start()) {
      digitalWrite(relayPin, HIGH);
      delay(500);
      digitalWrite(relayPin, LOW);
      delay(7000);
    }

}


As you can see it is very easy, if I press the right button combination I will trigger a relay.
I tested it severl times, cackled and patiently waited for my Trinket Pro to arrive.

Once the Trinket arrive it was a grumpy one so it didn't want to work via USB.
No biggie, I had an FTDI and I was able to flash the sketch just fine using this method.
Now the funny part...
If I press just the button "A" alone I immediately trigger the relay...
The same behavior if I press "B" alone or "Start" alone or "Z".
If I press "L" alone, on the other hand, it behaves like it should (no relay trigger).

Why? O_O
What is going on?

Thanks for your help!

ltpitt
 
Posts: 74
Joined: Thu Jan 03, 2013 5:22 am

Please be positive and constructive with your questions and comments.