Pages: [1]   Go Down
Author Topic: code arduino timer  (Read 435 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

first time i use mikroC make program for Timer

void main()
{
unsigned char clock[9];

int i,i1,y;

TRISB = 0x00;
TRISC = 0x00;
PORTC = 0x00;
TRISA = 0xFF;
ADCON1 = 0x07;      //inputs are set to digital

Lcd_Init(&PORTB);
Lcd_Cmd(LCD_CURSOR_OFF);
Lcd_Cmd(LCD_CLEAR);


                   T0CON=0x05;
                   TMR0H=0xC2;
                   TMR0L=0xF7;
                   INTCON.TMR0IF=0; //clear tmr0 overflow bit
                   T0CON.TMR0ON=1;    //Start timer0


     while(1)
{

Lcd_Chr(1,7,clock[7]+48);
Lcd_Chr(1,8,clock[6]+48);
              Lcd_Chr(1,9,clock[5]+48);
              Lcd_Chr(1,10,clock[4]+48);
              Lcd_Chr(1,11,':');
              Lcd_Chr(1,12,clock[3]+48);
              Lcd_Chr(1,13,clock[2]+48);
              Lcd_Chr(1,14,':');
              Lcd_Chr(1,15,clock[1]+48);
              Lcd_Chr(1,16,clock[0]+48);


              while(!INTCON.TMR0IF);
              T0CON.TMR0ON=0;

              clock[0]++;

.....

if(clock[0]>9)

              {

              clock[1]++;
              clock[0] = 0;

              }

              if(clock[1] >5)
                             {
                             clock[2]++;
                             clock[1]=0;
                             }


              if(clock[2]>9)
              {
                        clock[2]=0;
                        clock[3]++;
              }
              if(clock[3]>5)
              {
                        clock[3]=0;
                        clock[4]++;
              }
              if(clock[4]>9)
              {
                        clock[4]=0;
                        clock[5]++;
              }
           if(clock[5]>9)
           {
               clock[5]=0;
               clock[6]++;
           }
           if(clock[6]>9)
           {
               clock[6]=0;
               clock[7]++;
           }

           if(clock[6]==3&&clock[7]>3)    // return to start
              {
                        clock[6]=0;
                        clock[7]=0;
              }

for count

but I don't know how to code  to arduino
 such as :  Lcd_Chr(1,9,clock[5]+48);   How to write command to arduino

Could you tell me please Thank you.
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1016
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Arduino IDE contains examples how to use the LCD library, "File/Examples/LiquidCrystal".

http://arduino.cc/en/Reference/LiquidCrystal
http://arduino.cc/en/Tutorial/LiquidCrystal

If you want to write the code yourself, you could use the digitalWrite() function to toggle the select/enable/data lines.
http://arduino.cc/en/Reference/digitalWrite
Logged

Pages: [1]   Go Up
Jump to: