This week we need to take a board we've made and give it some new functionality. No more flashing with pre-written code.
Two weeks ago I added an LED and a button to Neil's [hello world](http://academy.cba.mit.edu/classes/embedded_programming/index.html#echo) board, so I'll start by making the LED turn on. I attached my LED to port PB2, and my switch to port PA7. To turn on the LED, we only need to do two things: enable PB2 as an output, and set it high. Here's code that does just that.
```
#include <avr/io.h>
#define led_pin (1 << PB2)
int main(void) {
// Configure led_pin as an output.
DDRB |= led_pin;
// Set led_pin high.
PORTB |= led_pin;
// Nothing left to do, so just spin.
while (1) {}
return 0;
}
```
Next let's use the button. The easiest approach is to use the button as a contact switch, turning on the LED only for the duration of the button press. To do this we'll need to configure pin PA7 as an input. I didn't add a pullup resistor on my board, so I also have to enable PA7's internal one. This will ensure that PA7 reads high when the button isn't pressed.