And… here we are

This week what we have all been fearing has happened to me: GitHub Copilot generated code for me which seems to meet all the requirements but which I don’t understand very much at all.

To date GitHub Copilot for me has just been mostly a useful auto-complete tool and it hasn’t given me any code which I didn’t understand. But with this code (to control two different hardware timers/counters on my Arduino) I don’t really understand it at all. I have passing familiarity with some of the registers used because I saw them named in the datasheet (which I have only skimmed so far) but basically I don’t understand how this works.

It is tempting to ignore the fact that I don’t fully understand and move on, but there’s a part of me which wants to return to the datasheet so I can understand what every assignment GitHub Copilot offered actually does and what every value it calculated implies. Is that the best use of my time?

Controlling Arduino Uno with Serial commands

@kline helped me with Phase 1 of my Crustacean Chirpy Chip Challenge project, which I have completed (sort of). I got the programming done but I didn’t do all the reading (yet).

Note to self: My Arduino Uno knockoff identifies itself as a “QinHeng Electronics USB Serial” USB device.

This is my code:

enum state { OFF, ON, FLASH };

enum state state = OFF;

int blink_pin = 13;

void setup() {
  pinMode( blink_pin, OUTPUT );
  Serial.begin( 9600 );
}

void loop() {
  if ( Serial.available() > 0 ) { read_command(); }
  switch ( state ) {
    case ON :
      digitalWrite( blink_pin, HIGH );
      break;
    case OFF :
      digitalWrite( blink_pin, LOW );
      break;
    case FLASH :
      int pin = digitalRead( blink_pin );
      digitalWrite( blink_pin, !pin );
      delay( 500 );
      digitalWrite( blink_pin, pin );
      delay( 500 );
      break;
  }
}

void read_command() {
  String command = Serial.readString();
  command.trim();
  command.toLowerCase();
  Serial.print( "Command: " );
  Serial.println( command );
  if ( command == "on" ) {
    state = ON;
  }
  else if ( command == "off" ) {
    state = OFF;
  }
  else if ( command == "flash" ) {
    state = FLASH;
  }
  else {
    Serial.println( "Unknown command." );
  }
}

This is my setup:

The code which would actually implement the spec, as given:

void read_command() {
  char c = Serial.read();
  switch ( c ) {
    case 'a' :
      state = ON;
      break;
    case 's' :
      state = OFF;
      break;
  }
}

Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C

Today I learned about Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C (Fourth Edition) by Yifeng Zhu while watching Lecture 9: Interrupts on YouTube. The full list of associated lectures are here: Short Lectures.

The SCSI Bus and IDE Interface: Protocols, Applications and Programming (2nd Edition)

I have this wonderful old book The SCSI Bus and IDE Interface: Protocols, Applications and Programming (2nd Edition). It was published in 1997 but is still available for purchase through Amazon.

The book comes with a floppy disk (that’s right: a floppy disk!). I had to buy a USB floppy disk drive to read it. I have made the content from the disk available in a tarball, here: scsi.tgz.

If you just want to read the files, those are here:

New Book Teardown: Learning The Art of Electronics: A Hands-On Lab Course | In The Lab With Jay Jay

This post is part of my video blog: In The Lab With Jay Jay.

Support this channel on Patreon: https://www.patreon.com/JohnElliotV

Silly Job Title: Master Planner

This video is part of the New Book Teardown feature of my video blog.

In this video I take a look at Learning the Art of Electronics: A Hands-On Lab Course by Thomas C. Hayes and Paul Horowitz published in 2016. The book has 1,140 pages and is a companion to The Art of Electronics 3rd Edition.

Some notes about things of interest we noticed in the book:

The Brain User’s Handbook: A Neuroscience-inspired Guide to Peace of Mind

I am reading The Brain User’s Handbook: A Neuroscience-inspired Guide to Peace of Mind which has this awesome image I want to share:


An imagined interaction between a human baby and a young LLM in training. They are sharing impressions about the endeavor of modeling the world from scratch. Image generated with DALLE-3 via ChatGPT