Prerequisites
Workflow
A new project with a
main.c
file associated with
it will be generated in Atmel Studio.main
’
function in the main.c
file with the following code
snippet:int main (void)
{
/* STK600 have eight User Buttons and eight User LEDs which can be connected to any IO pin using cables */
/* Configure PB0 as input (remember to connect SW0 to PB0 using a cable */
PORTB.DIRCLR = PIN0_bm;
/* Configure PB1 as output (remember to connect LED0 to PB1 using a cable*/
PORTB.DIRSET = PIN1_bm;
while (1)
{
/* Check the status of SW0 */
/* 0: Pressed */
if (!(PORTB.IN & (PIN0_bm)))
{
/* LED0 on */
PORTB.OUTCLR = PIN1_bm;
}
/* 1: Released */
else
{
/* LED0 off */
PORTB.OUTSET = PIN1_bm;
}
}
}
In
the code editor, the code may appear as shown in the figure below.