This week, for Embedded Programming, I first read up on some past student's pages to gain an idea of what my capabilities/options are. I found Ani Liu'x page and the resources linked on her page very useful. Additionally, I referenced Katherine Xiong's page for what I could do with the hello world board from two weeks ago.

But first, I had to mill the board I wired from two weeks ago.

Luckily, this board did not have any shorts or cold joints so the bootloader was successfully loaded on the first try. In terms of programming the board, I first loaded a blinking light Arduino program onto the board, and it worked as expected.

Then, to program the button as an input and the light as an output, I had only connected a button to the reset pin of the SAMD21, making me unable to achieve the intended purpose.

I decided to use the breakout board I designed for my output devices week, and add an external button that is connected to the 5V power supply and a PA pin in the board. Here is the code that programming the LED-button interaction. In the pinmodes in setup, I inputed the PA pins for the LED and the Button respectively. Since the button is connected to the 5V, it is initialized with an internal pulldown. If the buttonState is High, the pull down is in place, and the output is low. And vice versa for when the buttonState is Low.

An interesting adventure with Alec: With the help of Junhong, the bootloader was loaded to the breakout board to make it a programming device. However, there was a cold joint on one of the legs of the microcontroller making my computer unable to recognize the device. In the process of discovering this, I accidently pulled off the input component for programming the programmer. Thus, in the case that a mistake in the bootloader caused it to be unrecognized, I couldn't easily try reloading. Luckily, resoldering the cold joint resolved the issue and the board was recognized. Then, when programming it, I set up my code with the pullup resistor intending that the other side of the button was connected to ground as opposed to the power supply. Thus, my light was only going from dimmer to brighter when the button was pressed. To debug, this issue, I tried outputting to different ports which accidentally overwrote a USB input port. It was a bit scary since I thought I would need to reload the bootloader, but I couldn't do it given that the input component and traces were broken. When hope felt lost, Anthony mentioned that pressing the reset button twice takes us back to bootloader mode, and that resolved the difficult situation. (Good thing I connected a button to the reset then!)

Here's the button making the light blink!