JANET LIUHow to Make (almost) Anything

## Bootloading the board This week we were supposed to write code on our PCB that we created two weeks ago. Before I could do this, I had to see if I could actually get my computer and Arduino program to recognize my board. This turned out to be a super long and tough process. At first, Nathan tried to help me bootload it. We tried using openOCD on his laptop, but it was saying that it wasn't recognizing any board to program. After looking at it closely, we realized that the chip was soldered on the wrong direction. After desoldering it with a heat gun and soldering it back on in the right direction, openoOCD worked a little farther. But, it kept saying that there were memory writing issues. Nathan had never seen this error before, so he wasn'ts ure if it was in the hardware or the software. If it was a hardware issue, it could also be an issue with either my board or the 10-4 pin connector. Nathan recommended I download edbg on my own laptop to try and use that to load my board. After running through the steps on [the documentation](https://mtm.cba.mit.edu/2021/2021-10_microcontroller-primer/edbg/), I was still running into issues loading on the bootloader software. To figure out if it was an issue with my board or not, I tried using edbg to program a board I knew worked. However, edbg kept failing and having software issues. The descriptions of the errors were very vague (always just invalid error), so I had no idea if it was hardware or software. I almost gave up, ready to recreate a whole new board with a 10pin input so we didn't have to use the 10-4 pin converter and we could easily isolate which problem it was hardware wise. Then, Rob came in! Rob used the multimeter to check voltages and connections between traces. This was super helpful, since we eventually found out that my SamD11 chip wasn't actually connected to power. After looking at my week 6 documentation, I realized I forgot to put that trace in my schema. To fix it, we added in a wire to pin 12 and the output of my VCC regulator. Rob helped me solder on the wire to connect my chip to power, and we were able to use Rob's Linux edbg installation to successfully bootload! missing wire | added wire | bootloading success | :---------------:|:---------------:|:---------------: ![](../images/full/07/missing_wire.png) | ![](../images/full/07/added_wire.png) | ![](../images/full/07/bootloading_success!.png) To check if the board was working, we used some simple blink code that Rob had to check if things worked. At first, the light didn't work. After some voltage testing, we saw that the voltage to the resistor was actually correctly fluctuating between 0 and ~2.5-3 volts. We thought the LED I used was an infrared LED, so I swapped it out for a blue LED. After swapping it out, it successfully blinked and everything was finally ready to be programmed! <figure><img src="../images/full/07/blink.gif" width="500"/> </figure> ## [Writing Code](../code/blink.ino) Once my board was recognized by Arduino, coding it was actually really simple. I don't have much experience coding in the Arduino IDE, but I do a lot of programming as a CS major and a lot of the concepts are super similar. Neil and Brian also had a lot of great examples to pull from to understand how to structure my code and interface with the pins. I wrote a simple program to turn my LED on and off by clicking the button, linked in the header! <figure><img src="../images/full/07/final.gif" width="500"/> </figure>