/* Made by Jefferson Sandoval during the Embedded programming for the FabAcademy2021 * * This is just a simple testing code in C consisting of a button and a led, * the led is going to be On during the time that the butotn is pressed. * * This code was uploaded to a board with an Attiny1614 microcontroller. Documentation: * http://fabacademy.org/2021/labs/kamplintfort/students/jefferson-sandoval/assignments/week09/ */ #define F_CPU 3333333 //equals the frequency (20MHz) divided by 6 #include int main(void) { PORTA.DIR |= PIN3_bm; // Set LED as an output PORTA.DIR &= ~PIN2_bm; // Set button as an input PORTA.PIN2CTRL = PORT_PULLUPEN_bm; // Set PullUp resistors configuration while (true) { if (~PORTA.IN & PIN2_bm) // Check if button is pressed { // If button is pressed, Turn on LED PORTA.OUT |= PIN3_bm; // Turn led on } else { PORTA.OUT = ~PIN3_bm;} //If button is not pressed, keep the LED off } return (0); }