Week 8

Assignments: Output Devices



home

Assignments: Input Devices

group assignment:

• measure the power consumption of an output device

individual assignment:

• add an output device to a microcontroller board you've designed, and program it to do something


Light Sensor and Dimming


KiCad file is here: file

Final Text File for Arduino IDE file is here: file

Process Text File for Arduino IDE file is here: file

DIMMING TEST


This week I continued work from the previous on a phototransistor quadruple sensor and a super bright LED with a heatsink. I remilled the board to make the traces better, to add a logo, and to correct some issues with the three versus five volt powering of the LED. I spent time playing with the sensor settings and it became clear that the lowest resisted sensor was able to get values from extremely dark to extremely bright on a wide integer range from around 80 to around 4,000, which made it a better sensor than any of the other phototransistors with their respective resistances.

Each of the four 1206 footprint phototransistors has a series of resistances that are escalating from pin A3 to pin A0, and they resist from around 220 ohms down to about 4.5 ohms on the A3 pin. The goal of this circuit is to take the sensed light value in the room and use it to dim a light to a proportional brightness. In a bright room the light increases in intensity, and in a darker room the light becomes dimmer.

See below for an explanation of how this applies to my final project, where a more precise version of this circuit with a very bright LED array will be used to modulate the amount of light coming through gold leaf based on the amount of light being reflected or incident on the gold.

I was having trouble getting the LED to turn on. This was embarrassing because my solders were clean, but I don’t have enough experience to know how easy it is to create a bridge under a resistor that is hopping a trace. I spent several hours debugging with a multimeter, which was the first time I’ve done this on my own, and it was great. I learned a lot and became comfortable using the multimeter to read voltage as a difference across points and how to isolate problems using that information. It also gave me clarity about how many variables are at play in one of these boards.

I was reading a voltage difference between my ground pin and my pin and the copper surround of my trace, which was strange because nothing was connected to it. I designed the board with a pinout for the Xiao so that I can remove it if it fries or reuse it for other boards, which is helpful, but it also made me worried that there might be unintended connections. In the last photo in the gallery below, there is a tiny nugget of trace contacting the large solder bubble on my 5V pin, and it’s possible that this was causing an issue.

I eventually realized that the problem was with the solder connections on the anode and cathode of the super bright LED. The pins are very small and I used too much paste when soldering. Once I fixed that, the circuit worked. I also moved the LED to a smaller heatsink that was disconnected from the other copper island, and this solved the issue as well. It turns out the LED was also installed backwards because I misread the anode, cathode, and heatsink orientation diagram multiple times. Once the LED and sensors were working properly, I went into writing code for the board.


I went into the code and produced several versions of a dimmer switch that set high and low values for brightness and used pulse width modulation (PWM) to tailor the brightness of the LED to the brightness of the sensor reading. You can see here that my A0 through A3 pins have very different values when dim and very similar values when bright. It turns out that the A3 pin has the best readings, and I did not need to use the other three for this week. I plan to talk to Anthony to see if there is a way to use all four pins more effectively with a sensor like this phototransistor, but for now A3 worked well. It was able to read bright values more accurately than the more resisted phototransistors.

The final code I produced, which is available at the top, uses a linear transition between PWM values and sets a lower limit of around 80 from the A3 pin to a PWM value of 1. It sets a PWM value of around 250, which is as bright as the LED reached during testing, to a reading of around 4000. This was the highest level measured on the A3 reading when a headlamp flashlight was pointed directly at the sensor.



WHATS COMING NEXT

This week I set out to make a major move toward my final project, which involved mocking up a gold leaf test plate between two glass panes, paired with a super-bright LED array and a light-sensing input system. The goal was to create a micro-controlled LED module that reads the ambient light conditions in the room—whether interior light, indirect sun, or direct sun striking the panel—and outputs an equivalent level of LED light back into the space. In short: a feedback-based light collector that emits the same amount of light that hits it.

I worked with Anthony to design a system using four photoresistors, each wired with a different resistor value and assigned to one of the four analog pins on a Xiao 2040. This was necessary because the light range hitting a window-mounted panel is extremely wide, and a single sensor cannot accurately capture dim to bright conditions. By giving each of the four sensing circuits a different resistance range—from around 2.5 ohms to several hundred—we can collectively measure a full spectrum of ambient light and produce a proportional LED output from dim to very bright.

The whole assembly is intended to fit inside a wooden table-saw box. This object is an antique casting jig used to mold metal parts for table saw equipment, and its geometry makes it an ideal light box enclosure. The open slot where the blade would normally sit is the perfect location for the sensor array, along with a stepped capacitive-touch dimmer interface. I want as many touch steps as possible across this aperture—both for visual effect and for user experience—essentially a copper-band gradient along the length of the saw slot. After using the four analog pins, that leaves six data pins for the touch interface, excluding the one reserved for the LED array.

The LEDs are a set of extremely bright components that Anthony gave me. They required a custom footprint, which I designed this week, and I milled a small PCB plate as a test. The idea was to prototype the LED array and confirm spacing, heat concerns, and solderability before committing to the full panel version.



In producing the PCB, I ran into a number of issues—mostly time and tool-related. I assumed the shop would have the photoresistors I needed, but the only parts available were phototransistors, which require different wiring logic. This forced me to redesign the board in KiCad. I also struggled with the Fab Library, since many of the components I needed were hard to locate, so I ended up skipping the schematic stage entirely and worked directly in the PCB layout tool.

When I milled the board and attempted to solder it on Tuesday, I realized the cut was too deep. There was likely dust and two layers of tape stuck to the back of the PCB during milling, which caused the traces to lift and tear as I soldered. After repeatedly repairing lifted copper, I quit for the night—partly because the board had become unusable, and partly because I was exhausted and it wasn’t worth sacrificing more sleep for a test plate.

The plan for the coming week is to update the design to include both input and output functions on a single PCB, satisfying both assignments at once. I’ll produce the four-step photosensor array, integrate a milled capacitive-touch interface, and aim to get a dimmable light output running from the same board. More to come—I didn’t accomplish as much as I hoped this week, but it has been overwhelming. I’ll push forward this coming week.



PCB Traces & Sensor Results

These are the traces that I used to cut the preliminary and final PCB boards. Note that there are resistors used as trace jumps, and they are in fact necessary for the addition of resistance values to produce the certain sensing required in each of the four sensors.

Ultimately what occurred is that the most efficient sensor was pin A3, and that sensed from very dim to very bright on a scale of unitless measure of 40 nonunits to 4,000 nonunits.

I need to figure out why the other sensors were not as efficient, despite the advice from online and Anthony that different resistances would produce a better overall sensing. The pin on A3 with the lowest resistance to the phototransistor was far more able to produce the dimming that I desired.