HTMAA 25

home about me final project

week 8: input devices

Published: 2025-10-29

Overview

This week’s task was to create a microcontroller board with an input device. As will be seen, I largely took this as an opportunity to create a first version of the electronics I will need for my final project.

Group project

Using an oscilloscope, we measured the signals produced by a microphone as well as a phototransistor. (todo: link)

Designing

Goals

I wanted to use the input devices and output devices weeks to essentially create a first draft of the entire electronics of my final project - the peashooter. This meant that at minimum it should incorporate:

After consulting with Anthony, I was handed the VL53L1X Time-of-Flight Distance Sensor, the JYCRS390H 12V DC Motor, and the PZ22GR9120R DC Gearmotor.

The 12V motors also meant that I needed a 12V power supply to the board separate from the 5V USB line from my laptop.

Additionally, I wanted to include the following:

Schematic

My first general sketch looked something like:

// insert picture

Again another consultation with Anthony and some online sources, I made the following refinements:

This resulted in the following sketch:

// insert picture

And the following Fusion schematic:

// insert screenshot

PCB design

My first PCB layout was the following:

Which seemed neat and well laid-out, until I realized that ground was not connected. Most importantly, the source of two of my transistors did not contact ground. Since the motor current would be going through those points, I didn’t want to just put on a 0-ohm resistor.

After trying out a few other board layouts, e.g. the following (where I also updated the barrel jack to a component that we actually had)

I decided that laying out three motors nicely would be topologically impossible with a single-layer PCB and decided to abandon the extra motor. This led to the final layout of:

Making

Milling

Using the Bantam Tools Othermill, the PCB was cut from single-sided FR1. The total milling time was less than 10 minutes.

Assembly

Since I was using the pads under the microcontroller that I could not access with a traditional soldering iron, I knew I needed to reflow solder the microcontroller. Unfortunately, after trying and failing to do this for a decent amount of time, I was running out of time and decided to go for a much less elegant method of simply sticking wires where they needed to go:

// insert picture

Here, a thin wire was soldered to the Vin pad at the back of the microcontroller, then the entire back was covered with kapton tape and the microcontroller was traditionally soldered to the relevant pad. Since the back was no longer entirely flat, extra care was taken on this step.

The wire sticking out from underneath the back was then soldered to the original Vin trace. Instead of repeating the same thing for the ground pad from under the microcontroller, I wired ground over from an adjacent area.

The rest of the components went on uneventfully. Here is the final result:

// insert picture

Testing

Time of Flight sensor

#include <Wire.h>
#include <VL53L1X.h>

VL53L1X sensor;

void setup()
{
  while (!Serial) {}
  Serial.begin(115200);
  Wire.begin();
  Wire.setClock(400000); // use 400 kHz I2C

  sensor.setTimeout(500);
  if (!sensor.init())
  {
    Serial.println("Failed to detect and initialize sensor!");
    while (1);
  }

  sensor.setDistanceMode(VL53L1X::Long);
  sensor.setMeasurementTimingBudget(50000);

  sensor.startContinuous(50);
}

void loop()
{
  Serial.print(sensor.read());
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }

  Serial.println();
}
#include <Wire.h>
#include <VL53L1X.h>

#define RED 17
#define GREEN 16
#define BLUE 25 // from XIAO RP2040

VL53L1X sensor;

void setup()
{
  pinMode(RED, OUTPUT); digitalWrite(RED, HIGH);
  pinMode(GREEN, OUTPUT); digitalWrite(GREEN, HIGH);
  pinMode(BLUE, OUTPUT); digitalWrite(BLUE, HIGH); // high = off

  Wire.begin();
  Wire.setClock(400000); // use 400 kHz I2C

  sensor.setTimeout(500);
  if (!sensor.init())
  {
    digitalWrite(RED, LOW);
    while (1);
  }

  sensor.setDistanceMode(VL53L1X::Long);
  sensor.setMeasurementTimingBudget(15000);
  sensor.startContinuous(15);
}

void loop()
{
  int dist = sensor.read();

  if (dist < 300) {
    digitalWrite(BLUE, LOW); // on
  } else {
    digitalWrite(BLUE, HIGH); // off
  }
}

// insert picture/video

Beam-break sensor

Testing code:

#define IRLED 26
#define PHOTOTRANSISTOR 27

void setup() {
  pinMode(IRLED, OUTPUT);
  pinMode(PHOTOTRANSISTOR, INPUT);

  Serial.begin(9600);
}

void loop() {
  Serial.println(analogRead(PHOTOTRANSISTOR));
  digitalWrite(IRLED, HIGH);
  delay(200);

  Serial.println(analogRead(PHOTOTRANSISTOR));
  digitalWrite(IRLED, LOW);
  delay(200);
}

(ping pong ball, hand, ping pong ball)

(ping pong ball, hand, piece of paper, rolling ping pong ball)

Takeaways

This is definitely a draft 1 board, but everything works! Will probably use this to test things for now and then create a board with better layout (and all the correct pins, soldering etc.) for actual final creation.

Plan for next week: Add motors and actually code it up to respond the way it should for all its inputs.