Loading Session1-LF/Task2-LF.c +14 −4 Original line number Diff line number Diff line Loading @@ -23,10 +23,10 @@ //Fill in the defines with the information you found on the board/in the user guide. // LED #define LED0 //Fill in pin number #define LED0 5 //Fill in pin number // Button #define SW0 //Fill in pin number #define SW0 6 //Fill in pin number int main(void) { Loading @@ -53,9 +53,11 @@ int main(void) * It's your time to do some stuff! Do the following: * 1 - Set LED0 as output * 2 - Set SW0 as input * 3 - Enable pull-up on button SW0 * 3 - Enable pull-up on button SW0 (Not necessary here as we have an external pull-up, but in case you dont have one in the future, dont forget!). */ PORTF.DIRSET = (1 << LED0); PORTF.DIRCLR = (1 << SW0); //PORTF.PIN6CTRL |= (1<<PORT_PULLUPEN_bp); //Not necessary as the button already had an external pullup. while (1) { /* Loading @@ -75,6 +77,14 @@ int main(void) * 2 - if so, turn the LED on * 3 - if not, turn the LED off */ if(!(PORTF.IN & (1<<SW0)))//Check if SW0 is pressed { PORTF.OUTCLR = (1<<LED0);//Set LED0 high } else { PORTF.OUTSET = (1<<LED0);//Set LED0 low } } } Loading
Session1-LF/Task2-LF.c +14 −4 Original line number Diff line number Diff line Loading @@ -23,10 +23,10 @@ //Fill in the defines with the information you found on the board/in the user guide. // LED #define LED0 //Fill in pin number #define LED0 5 //Fill in pin number // Button #define SW0 //Fill in pin number #define SW0 6 //Fill in pin number int main(void) { Loading @@ -53,9 +53,11 @@ int main(void) * It's your time to do some stuff! Do the following: * 1 - Set LED0 as output * 2 - Set SW0 as input * 3 - Enable pull-up on button SW0 * 3 - Enable pull-up on button SW0 (Not necessary here as we have an external pull-up, but in case you dont have one in the future, dont forget!). */ PORTF.DIRSET = (1 << LED0); PORTF.DIRCLR = (1 << SW0); //PORTF.PIN6CTRL |= (1<<PORT_PULLUPEN_bp); //Not necessary as the button already had an external pullup. while (1) { /* Loading @@ -75,6 +77,14 @@ int main(void) * 2 - if so, turn the LED on * 3 - if not, turn the LED off */ if(!(PORTF.IN & (1<<SW0)))//Check if SW0 is pressed { PORTF.OUTCLR = (1<<LED0);//Set LED0 high } else { PORTF.OUTSET = (1<<LED0);//Set LED0 low } } }