Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
simenpf
attinykurs
Commits
e620a045
Commit
e620a045
authored
Mar 05, 2019
by
Johan Vaarlid - M19939
Browse files
updated Tas2-LF.c with CNano button and LED
parent
7f626ddd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Session1-LF/Task2-LF.c
View file @
e620a045
...
...
@@ -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
)
{
...
...
@@ -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
)
{
/*
...
...
@@ -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
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment