Thursday, June 15, 2017

Albert's Gift: Part 2

Damn I suck at keeping up with new hobbies. I've been busy being lazy keeping up to date on this blog, but I'm on summer vacation right now with no job and continuing to be a lazy guy. However, I have been slowly but surely working on Albert's gift. I believe the last post talked about the 3D enclosure for the circuitry. I tried printing out the enclosure straight from the files the Adafruit tutorial gave, but something wonky happened and the walls of the enclosure was too small for the top and bottom pieces to fit on. Not being well versed in 3D printing and its software, I attempted to simply scale the wall piece a little bit to allow for enough room, but the end result is some thinly printed plastic that is now a bit too loose.


Shown above is the side of the enclosure that allows the arduino to be plugged with either a micro-USB cable or a 5V DC supply. I didn't have enough time to fix the design and print a better side, but it holds well enough. It just looks like a termite mound.

After the 3D printing step was done, I had to solder on a few wires to the Adafruit Trellis board so it can connect with the arduino inside. But before I go on, I want to talk about a problem I encountered yesterday when I was working on the code.

I originally was using an arduino R3 as the microprocessor. As I was attempting to write code to simulate one of the buttons typing in a capital "A", I learned that the R3 was not able to use the "Keyboard" library due to its installed microcontroller. Believing that I could surely pull it off anyways through some sort of manual update of the firmware that would disregard this restriction, I did a quick Google search and found that it was possible, but I would have to solder on a 10K ohm resistor to a couple of pins on the bottom of the R3. I figured that since I don't have a soldering kit and the 10K ohm resistor attached to the bottom would make the R3 too big for the enclosure, I simply went out and bought an arduino Leonardo. The microprocessor on this arduino was actually able to naturally use the "Keyboard" library and allow for what I wanted.

Back to the soldering of the Trellis board, below you can see a quick picture I just took of the circuitry between the Trellis board and the arduino Leonardo.

Furthermore, I soldered on 16 LEDs to each of the 16 button locations so when one is pressed, it would light up until released.

With the hardware complete, I now move on to the coding of this project. So far, I have been able to simulate a capital "A" when pressing whatever button I code it to be (I made it the button labeled "1" on the Trellis board). Preparing myself for coding all buttons to simulate a keystroke of the keyboard, I am attempting to make a switch statement. The code is written so that it goes through each button (1-16 on the Trellis, but indexed 0-15 in the code) in ascending order, checking which button has just been pressed. Whatever button it's checking is saved into the aptly labeled "i" integer which will be the expression used in the switch statement. I will have 16 cases for each number in the closed set   [0, 15] and program them to simulate a single letter of the alphabet from A to P, which should be the first 16 letters.

I will test with only the first 2 buttons to see if this switch statement will work as intended, and later code in the LED functionality. 

Fingers crossed.