Commit 2132d3cd by phkarl

Upload New File

parent 1b628419
Showing with 140 additions and 0 deletions
/*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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment