9660 Debugging tool for controller outputs - Code included

Lower Canada College

Published on 2019-11-09

I can't seem to get the post to show up. Not sure why.


I wanted to learn about the CRCLib so I wrote a piece of code to output the button values and the Joystick

Values. This is not beautiful, but it is functional.

You need to use the Tools->Serial Monitor to see the output. Arduino debugging is a pain. The output is ugly, scrolling continuously, but that is the way the serial communication works.

USB connect to the 9660, link the manette, run the serial monitor and you are off.

Code is at the bottom



#include <CrcLib.h>
using namespace Crc;
void setup()
    //Not necessary
void loop()
  unsigned char LjoyY = Crc::CrcLib::ReadAnalogChannel(ANALOG::LCHANY);
  unsigned char LjoyX = Crc::CrcLib::ReadAnalogChannel(ANALOG::LCHANX);
  unsigned char RjoyY = Crc::CrcLib::ReadAnalogChannel(ANALOG::RCHANY);
  unsigned char RjoyX = Crc::CrcLib::ReadAnalogChannel(ANALOG::RCHANX);
  bool selectButton = CrcLib::ReadDigitalChannel(BUTTON::SELECT);
  bool startButton = CrcLib::ReadDigitalChannel(BUTTON::START);
  bool L1Button = CrcLib::ReadDigitalChannel(BUTTON::L1);
  bool L2Button = CrcLib::ReadDigitalChannel(BUTTON::L2);
  bool L3Button = CrcLib::ReadDigitalChannel(BUTTON::L3);
  bool R1Button = CrcLib::ReadDigitalChannel(BUTTON::R1);
  bool R2Button = CrcLib::ReadDigitalChannel(BUTTON::R2);
  bool R3Button = CrcLib::ReadDigitalChannel(BUTTON::R3);
  bool upButton = CrcLib::ReadDigitalChannel(BUTTON::UP);
  bool rightButton = CrcLib::ReadDigitalChannel(BUTTON::RIGHT);
  bool downButton = CrcLib::ReadDigitalChannel(BUTTON::DOWN);
  bool leftButton = CrcLib::ReadDigitalChannel(BUTTON::LEFT);
  bool greenButton = CrcLib::ReadDigitalChannel(BUTTON::GREENONE);
  bool redButton = CrcLib::ReadDigitalChannel(BUTTON::REDTWO);
  bool blueButton = CrcLib::ReadDigitalChannel(BUTTON::BLUETHREE);
  bool pinkButton = CrcLib::ReadDigitalChannel(BUTTON::PINKFOUR);
   Serial.print(" L2-");Serial.print(L2Button); 
   Serial.print(" R2-");Serial.print(R2Button); 
   Serial.print(" L1-");Serial.print(L1Button); 
   Serial.print(" R1-");Serial.print(R1Button);
   Serial.print(" L3-");Serial.print(L3Button);  //no idea what button this is 
   Serial.print(" R3-");Serial.print(R3Button);  //no idea what button this is 
   Serial.print(" SEL-");Serial.print(selectButton); 
   Serial.print(" STAR-");Serial.print(startButton); 
   Serial.print(" up-");Serial.print(upButton); 
   Serial.print(" down-");Serial.print(downButton);
   Serial.print(" right-");Serial.print(rightButton); 
   Serial.print(" left-");Serial.print(leftButton);
   Serial.print(" G1-");Serial.print(greenButton); 
   Serial.print(" Re2-");Serial.print(redButton);
   Serial.print(" B3-");Serial.print(blueButton); 
   Serial.print(" P4-");Serial.print(pinkButton);
   Serial.print(" LJoy(");Serial.print(LjoyX); Serial.print(",");Serial.print(LjoyY); Serial.print(")");
   Serial.print(" RJoy(");Serial.print(RjoyX); Serial.print(",");Serial.print(RjoyY); Serial.print(")");

Problem was the screenshot I was trying to include. Maybe I exceeded a maximum post size?


Please note that the serial communication rate is bumped to 19200 baud instead of the default 9600. You need to change the rate on the serial monitor to match or you will get output that looks like is is written in Cyrillic.


Xavier St-Pierre

Published on 2019-11-11

Hey there!

Nice start! Here's a few pointers that might be useful to know:

L3 and R3 correspond to the buttons when you press on the joystick! They make a satisfying click noise.

You can print multiple things in a line using the following syntax:

 Serial.print(" L2-");Serial.print(L2Button); becomes
 Serial.print(" L2-" + L2Button); 

You can also format prints with "/n" (line return) and "/t" (tab)

We'll check around about the screenshot issue.

Xavier St-Pierre

Published on 2019-11-11

Looks like we can't edit responses...yet! I guess a second post will suffice for now.

Using combined prints like the 

Serial.print(" L2-" + L2Button);
Prints garbage unless you use the String class,so you're better off doing like you did! :)

As said on the wiki, make sure to remove prints from your code when you are doing serious piloting! Prints are a very long thing to execute and may result in delay in your executions.