03

Embedded Programming

For this week I want to ramp up a satellite dish I found by the side of the round.
What I've done already:

  • Cut out all the wires / take it from off its stand
  • Paint my roomie's face big and in blue
  • Give the little satellite arm a hot dog (since my roommate is an appreciator)
My vision of what it could be:
  • Let the arm be pullable, the hot dog tantalizingly retractable.
  • Separte the mouth, cut it along its teeth so it can open wider.
  • Introduce a sense of play: you tug for the hot dog, the mouth gets angry and closes faster, etc.
Side note: Halloween is also fast approaching and what better candy dispenser than one this satellite holding out its welcoming bowl of candy. And when you grab a handful it starts retracting and putting it in its mouth!

State of the satellite & doodles for where it's headed next...

Proposed flow diagram

Hello World on the Seeed XIAO RP2040

Following this this great tutorial, I downloaded Thonny, installed MicroPython onto the microcontroller, and got a little hello world to run / display some lights. It was awesome, but then also perhaps unsurprising to see the call out to Neil's contribution in the XIAO documentation.

As a first test I programmed the main LED to slowly fade from blue to red. (For prosperity this is a link to Neil's helpful ffmpeg shortcuts)

Soldering

Now to get some input/output going...
First to solder the pins into the board, and coincidentally my first time soldering.

But yikes! I shorted a couple pins together. A little copper wipe up to the rescue (thanks Kristan for the suggestion)

Pinout Confusion

Okay great! now all that's left is to write the program. But hey why am I not able to output a voltage from Pin 1? Wait even when I try with the Digilent waveform generator none of the pins are reading out any voltage. And what's Pin 17? How are there 30 active pins on this board according to Micropython!

Long story short, after writing a little script to debug by checking the state of every Pin, it became clear that the Pin mapping was not what I thought. 30 seconds of googling and pin out to the rescue! Man are the Micropython pin numbers really wildly unintuitive. I guess this is why it's important to read the datasheet.

The Four Moods of the Hot Dog Angler

Peering into the brain of the hot dog wrangler, we see four distinct states dependent on certain pin inputs:

  • When to be asleep: No input to any pinouts. The satellite has its mouth closed & hotdog extended, perhaps luring in prey?
  • When to be evil: Input to only the evil pin. The prey has taken the bait! The satellite reels in the hot dog (with unsuspecting victim attached) and starts gnashing its teeth
  • When to be neutral: Input to only the neutral pin. The satellite feels at home and at peace. Enjoys its hotdog, discretely lifting it to its mouth and taking a few calm bites every now and then
  • When to be confused: Input to both neutral pin and evil pin. The satellite is in a state of shock. Someone has threatened their hot dog! No longer the apex predator, in desperate H.D. defense the satellite closes its mouth, and starts to tremble - hot dog shaking back and forth.
Testing the program by outputting a voltage to Pin 0, linking each emotion to a color (Blue - Asleep, Red - Evil, Green - Neutral, Yellow - Confused), and checking/printing each emotion every second. We can peer into the monster's motor cortex: