Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phkarl
/
IAX0583
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2132d3cd
authored
Dec 10, 2018
by
phkarl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
1b628419
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
140 additions
and
0 deletions
lab12/mainv1.c
lab12/mainv1.c
0 → 100644
View file @
2132d3cd
/*H*****************************************************************************
* FILENAME : main.c
*
* DESCRIPTION : Includes main() function with while(1) loop where your code
* should go.
*
* PUBLIC FUNCTIONS :
*
* NOTES :
*
* COPYRIGHT : Copyright 2018 Hardi Selg
*
* AUTHOR : Hardi Selg CONTACT : hardi.selg@ati.ttu.ee
*
* START DATE : 06.11.2018
*
* CHANGES :
*
*
*H*/
//Libraries
#include <xc.h>
#include <sys/attribs.h>
#include "config.h"
#define DELAY100MS 100
//Main program
int
main
(
void
)
{
//Has to be the first function call after main()
init
();
//Includes PIC16F690 basic configuration
int
i
;
int
countBtn
=
0
;
//Loop forever
while
(
1
)
{
//Write your code here
DelayForAproxmSeconds
(
DELAY100MS
);
//if(BTND == 1)
//{
// LED0 = 1;
//}
//else
//{
// LED0 = 0;
//}
//LED_SetGroupValue(SW0 + SW1 + SW3 + SW4 + SW5 + BTNL);
//WriteDigits(SEGM0, 0b1100, SW6);
//WriteDigits(SEGM1, 0x0b, SW7);
//WriteDigits(SEGM2, 10, BTNL);
//WriteDigits(SEGM3, 0, DOT_ON);+
if
(
BTND
==
1
)
{
countBtn
++
;
int
count
=
0
;
if
(
SW0
==
1
)
{
count
++
;
}
if
(
SW1
==
1
)
{
count
++
;
}
if
(
SW2
==
1
)
{
count
++
;
}
if
(
SW3
==
1
)
{
count
++
;
}
if
(
SW4
==
1
)
{
count
++
;
}
if
(
SW5
==
1
)
{
count
++
;
}
if
(
SW6
==
1
)
{
count
++
;
}
if
(
SW7
==
1
)
{
count
++
;
}
WriteDigits
(
SEGM0
,
count
,
DOT_OFF
);
LED0
=
0
;
LED1
=
0
;
LED2
=
0
;
if
(
count
%
4
!=
0
)
{
if
(
count
%
4
==
1
)
{
LED0
=
1
;
}
if
(
count
%
4
==
2
)
{
LED0
=
1
;
LED1
=
1
;
}
if
(
count
%
4
==
3
)
{
LED0
=
1
;
LED1
=
1
;
LED2
=
1
;
}
}
if
(
countBtn
<
10
)
{
WriteDigits
(
SEGM2
,
countBtn
,
DOT_OFF
);
}
else
{
int
seg2
;
int
seg3
;
seg2
=
countBtn
%
10
;
seg3
=
(
countBtn
-
(
countBtn
%
10
))
/
10
;
WriteDigits
(
SEGM2
,
seg2
,
DOT_OFF
);
WriteDigits
(
SEGM3
,
seg3
,
DOT_OFF
);
}
}
WriteDigits
(
SEGM1
,
16
,
DOT_OFF
);
}
return
0
;
}
\ No newline at end of file
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