caramoan tour package

caramoan tour package

Author Topic: LCD counter --> PIC16f628a + LCD  (Read 976 times)

Offline carlsfootprints

  • Lead Acid Battery
  • *******
  • Posts: 629
  • Pogi/Ganda Points: 25
LCD counter --> PIC16f628a + LCD
« on: April 04, 2010, 07:48:44 AM »
schematic:



source code:

Code: [Select]
#include <htc.h>
#include <stdio.h>
#include "lcd.h"

#define _XTAL_FREQ 4000000

__CONFIG(XT & WDTDIS & PWRTDIS & UNPROTECT);

unsigned int num = 0;
unsigned char s[1];

void lcd_display_num(void)
{
lcd_clear();
lcd_puts("number");
lcd_puts(num);
sprintf(s,"%d",num);
lcd_puts(s);
}

void init_PORTS(void)
{
TRISB &= ~0x0F;
PORTB &= ~0x0F;
TRISB |= 0xF0;
PORTB |= 0xF0;

TRISA &= ~0x03;
PORTA &= ~0x03;
}

void main()
{

init_PORTS();

lcd_init();
lcd_clear();
lcd_puts("**COUNTER**");

__delay_ms(50);

lcd_clear();
lcd_puts("You can start counting!");

while(1)
{
if (RB7 == 0)
{
lcd_clear();

__delay_ms(30);

num++;

lcd_display_num();
}
}
}

sirs,

may mga problem ako regarding dito..

simple counter lang naman po siya.. kaso iba ung output na nangyayari sa expected ko..

dun sa schematic above..

1st press ng button: eto ang output <number 1> // no space dapat
2nd press: <number2> // tama ung output
3rd press: <number 3> // may space na naman
4th press: <number4> // tama ulit ung output
5th press: <numerd5> // may d na lumabas between r and 5
6th press: <number6> // tama ulit ung output
7th press: <number...> // lumalabas na ung initial display ko
8th press and so on.. // nagshishift po ung initial display ko gada press nung button.. ung number lang po ung maayos na display.. ung mga sunod.. nagshishift na lang..

tapos everytime na magbubuild ako.. may warning na ganito..

illegal conversion of integer to pointer

pakiramdam ko.. sa lcd_display_num() function nagmumula ang problem.. hmm..

thanks in advance po..
never saturate..

Philippine Electronics Forum

LCD counter --> PIC16f628a + LCD
« on: April 04, 2010, 07:48:44 AM »

Offline 'yus

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4251
  • Pogi/Ganda Points: 299
  • Gender: Male
  • hw -> fw -> sw
    • yus' projects
Re: LCD counter --> PIC16f628a + LCD
« Reply #1 on: April 04, 2010, 09:02:27 AM »
no need na ata dun sa line na "lcd_puts(num);"
para saan sana yan? baka pwedeng i-delete na lang.
join  - Philippine Electronics and Robotics Enthusiasts Club - www.philrobotics.com

Philippine Electronics Forum

Re: LCD counter --> PIC16f628a + LCD
« Reply #1 on: April 04, 2010, 09:02:27 AM »

Offline carlsfootprints

  • Lead Acid Battery
  • *******
  • Posts: 629
  • Pogi/Ganda Points: 25
Re: LCD counter --> PIC16f628a + LCD
« Reply #2 on: April 04, 2010, 09:27:06 AM »
ang gwapo mo ate yus.. hehe..

solve na agad..
never saturate..

Philippine Electronics Forum

Re: LCD counter --> PIC16f628a + LCD
« Reply #2 on: April 04, 2010, 09:27:06 AM »

Offline carlsfootprints

  • Lead Acid Battery
  • *******
  • Posts: 629
  • Pogi/Ganda Points: 25
Re: LCD counter --> PIC16f628a + LCD
« Reply #3 on: April 04, 2010, 09:56:13 AM »
ate yus,

follow-up question lng.. ung size nung char array na dineclare ko, kahit ano, oks lang naman.. ano pong relevance nun?

tapos, pwede ko po bang gamitin ung sprintf kahit strings na ung ididisplay ko? nagtatry ako kaso failed..
never saturate..

Philippine Electronics Forum

Re: LCD counter --> PIC16f628a + LCD
« Reply #3 on: April 04, 2010, 09:56:13 AM »

Offline 'yus

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4251
  • Pogi/Ganda Points: 299
  • Gender: Male
  • hw -> fw -> sw
    • yus' projects
Re: LCD counter --> PIC16f628a + LCD
« Reply #4 on: April 04, 2010, 10:08:51 AM »
yung size ng "s" array mo dapat equal(or mas malaki) sa length ng string na idi-display mo.

yung unang size na ginamit mo, w/c is "1", is gumana kasi single digit pa lang ang dini-display mo.
join  - Philippine Electronics and Robotics Enthusiasts Club - www.philrobotics.com

Philippine Electronics Forum

Re: LCD counter --> PIC16f628a + LCD
« Reply #4 on: April 04, 2010, 10:08:51 AM »

Offline carlsfootprints

  • Lead Acid Battery
  • *******
  • Posts: 629
  • Pogi/Ganda Points: 25
Re: LCD counter --> PIC16f628a + LCD
« Reply #5 on: April 04, 2010, 02:19:40 PM »
ahh.. ok.. tnx ulit..
never saturate..

Offline carlsfootprints

  • Lead Acid Battery
  • *******
  • Posts: 629
  • Pogi/Ganda Points: 25
Re: LCD counter --> PIC16f628a + LCD
« Reply #6 on: April 04, 2010, 04:54:23 PM »
dapat pla int pa rin ang declaration ko kahit char string ang ididisplay...

working na..

next, eeprom..
never saturate..

Philippine Electronics Forum

Re: LCD counter --> PIC16f628a + LCD
« Reply #6 on: April 04, 2010, 04:54:23 PM »

 

Privacy Policy

Contact Us: elabph@yahoo.com