* Check out the ATtiny4809 datasheet to find the correct ports and pins
*/
* Take a look at the Atmega4809 Curiosity Nano board and locate "SW0" and "LED0".
* Right below each of them you can see which pin they are connected to. For example, if it said PD5, this would mean Port D and Pin 5.
* This info can also be found in the ATmega4809 Curiosity Nano Hardware User Guide here: http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega4809-Curiosity-Nano-HW-UG-DS50002804A.pdf to find the correct ports and pins
*/
//Fill in the defines with the information you found on the board/in the user guide.
// LED
#define LED0 4 //On port D
#define LED0 //Fill in pin number
// Button
#define SW0 2 //On port C
#define SW0 //Fill in pin number
intmain(void)
{
/*
* We want to send signals to the LEDs, in order to turn it off and on.
* We also want to be able to read the switches.
* This is done by setting bits in the PORTx.DIR register (in this case PORTD.DIR and PORTC.DIR)
* This is done by setting bits in the PORTx.DIR register (in this case PORTF.DIR)
* PORTx.DIR: 1 is output, 0 is input
* LED: 1 LED is off, 0 LED is on
* Button: 1 Button is open, 0 button is pressed
...
...
@@ -41,7 +45,7 @@ int main(void)
/**
* In order to read from the switches, we need to give it a ground reference, via a pull-up resistor.
* If we don't, the switch will have a floating ground, and hence its value will be undefined.
* On the ATtiny4809, we enable pull-up by setting the "PORT_PULLUPEN" flag in "PORTx.PINnCTRL" high.
* On the ATmega4809, we enable pull-up by setting the "PORT_PULLUPEN" flag in "PORTx.PINnCTRL" high.