Trinket debugging…

One of the nice things about debugging code on the Arduino is that you can send debugging information back out the serial port. The arduino can do this because it has a separate microcontroller to handle the USB communication duties.

The Trinket, however, does not have a separate microcontroller – the USB communication is handled by the same microcontroller your code runs on.

I needed to do some debugging, and decided to do something very old school. I wrote some code like this:

temp = valueIWantToView

digitalWrite(0, HIGH);
digitalWrite(0, LOW);

for (int I = 0; I < 8; i++)
{
    if (temp & 080)
    {
        digitalWrite(0, HIGH);
    }
    else
    {
        digitalWrite(0, LOW);
    }
    temp <<= 1;
}

I ran this on a timer interrupt, hooked up my scope to pin 0, and I could then read the bits directly off the scope.


So, what do you think ?