summaryrefslogtreecommitdiff
path: root/Example01/main.c
blob: 76a47b20bacb2a306539d9eb10f3e9dde77a8f20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#define F_CPU 3333333
#include <avr/io.h>
#include <stdbool.h>

int main(void) {
  PORTF.DIR &= ~PIN3_bm; // button as input
  PORTF.DIR |= PIN4_bm;  // green as output
  PORTF.DIR |= PIN5_bm;  // red as output

  while (1) {
    bool buttonp = PORTF.IN & PIN3_bm;
    PORTF.OUT = 1 << (buttonp ? PIN4_bp : PIN5_bp);
  }
}