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.

Quality capacitors: Nichicon

Note to self: I was watching EEVblog #378 – Dumpster Diving Teardown Repair and EEVblog #763 – Dumpster Plasma TV Bad Cap Repair and Dave Jones says Nichicon make high quality capacitors. Apparently Panasonic, Nippon Chemi-Con, Rubycon, and Cornell Dubilier are also good.

Soldering tips from Dave Jones

In his video EEVblog #186 – Soldering Tutorial Part 3 – Surface Mount Dave Jones says to use soldering iron temperature of 300°C to 350°C. He set his hot air gun at 350°C.

He also recommends 4x or 6x magnifications for 0402 SMD and recommends not to use them (or smaller) unless you have to because they can increase manufacturing costs due to being small and fiddly and requiring magnification during soldering. The smaller components can affect yield.

For solder he recommends 0.46mm solder (recommended Multicore brand). And flux. Always use flux.

Also he’s on the record as preferring a chisel tip. In this video he also demoed a thing called a “well tip“, which I have never seen or used before. Apparently good for drag soldering?

While I was researching this post I came across the Hakko Product Lineup, they have some nice looking kit!

p.s. in EEVblog #180 – Soldering Tutorial Part 1 – Tools Dave suggests solder in this order:

  1. 62sn/36pb/2ag
  2. 63sn/37pb
  3. 60sn/40pb

The first one with silver in it can be good for some SMT devices. The second one has a more stable melting point. The third is tried and tested but has variable range of melting points.

Note: sn = tin; pb = lead; ag = silver.