Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
attinykurs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
avrkurs
attinykurs
Commits
e620a045
Commit
e620a045
authored
Mar 05, 2019
by
Johan Vaarlid - M19939
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated Tas2-LF.c with CNano button and LED
parent
7f626ddd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
Session1-LF/Task2-LF.c
Session1-LF/Task2-LF.c
+14
-4
No files found.
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
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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