# Week 7: Embedded Programming
Back to Home
## Setting Up
I didn't trust my programmer, and had heard tell from others that their programmers were mysteriously failing, so I availed myself of the AVRISP mkII programmer again. As before, I connected the black wire on the FTDI connector to the ground on my FTDI pin and the pink strip on the programmer header pin connector to the VCC on the board's header pin. When connected, there should be one stable green light (red if board is disconnected) and one flashing green light (when connected to computer).
## Coding
I admit, I did not have the drive to above and beyond here, so I just followed previous student Andrew Kriebel's guide to making the LED turn on when the button is pressed. I did it two ways, one in C and one with the Arduino IDE. The latter didn't end up working, but the former did.
### Programming ATtiny in C, or a confusion of 0s
I've actually never coded in C before, so some of the syntax (declaring variables beforehand? what nonsense) was strange to me. It was straightforward enough to work from a template, though, after figuring out that the digit in the 0b- code that corresponded to a pin name (not pin number, perse) on the ATtinywas the number of places it was from the right. You set the pin to HIGH by making that digit 1, LOW by making it 0. When button is pressed, its pin is LOW, we set the LED pin to HIGH.
In addition to the actual code, I guess in C you need to write a makefile to compile it (again, what nonsense). I modified Neil's makefile, removing everything except the parts needed to program the board through usbtiny or AVRISP, and changed the PROJECT variable to reflect my c file's name.
Loading the program went surprisingly smoothly:
Amazingly, it worked!
### Programming ATtiny with Arduino IDE
Again I followed Andrew Krieber's tutorial, changing pin settings (pin number this time) not match mine. The code was verified and it uploaded without error, but the LED didn't turn on when I pressed the button.
These were my settings:
### Update 11/13/18
I figured out why this wasn’t working: the pin configurations were wrong. I thought that the Arduino pin numbers corresponded to the 1-14 physical pin layout on the t44; it does not! Refer to this schematic to figure out what the right numbers to use in Arduino are.