27/08/2016
Disini kami sertakan salah satu contoh projek.
***********************************************************************************
sbit LCD_RS at RC2_bit;
sbit LCD_EN at RC3_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;
sbit LCD_RS_Direction at TRISC2_bit;
sbit LCD_EN_Direction at TRISC3_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
int temp, output,enterState = 0, upDown = 0, u;
int ledState = 0;
char t[15], kk[20];
RA1 PORTA.RA1
UP PORTA.RA2
DOWN PORTA.RA3
LED1 PORTD.RD1
void clearLcd();
void writeToLcd( int upDown );
void main() {
// make all portA as digital except ra0
ADCON1 = 0b11111110;
TRISA = 0xFF;
TRISD = 0x00;
PORTA = 0xFF;
PORTD = 0x00;
Lcd_Init();
Lcd_Cmd( _LCD_CLEAR );
Lcd_Cmd( _LCD_CURSOR_OFF );
Lcd_Out( 1, 1, "Initializing...." );
Delay_ms( 50 );
clearLcd();
ADC_Init();
while ( 1 ) {
temp = ADC_Read( 0 );
temp = ( (temp / 1023.0) *5 ) * 100;
IntToStr( temp, t );
u = Ltrim(t);
Lcd_Out( 1, 1, strcat( u, " C" ) );
if ( u > ledState ) {
LED1 = 0;
}
else {
LED1 = 1;
}
if ( RA1 == 0 ) {
if ( enterState == 0 ) {
Lcd_Out( 2, 1, "Enter Value : " );
enterState = 1;
}
else {
Lcd_Cmd( _LCD_SECOND_ROW );
clearLcd();
Lcd_Out( 2, 1, "OK" );
ledState = upDown;
enterState = 0;
}
}
if ( enterState == 1 ) {
if ( UP == 0 ) {
upDown++;
writeToLcd(upDown);
}
if ( DOWN == 0 ) {
upDown--;
writeToLcd(upDown);
}
}
}
}
void clearLcd () {
Lcd_Cmd( _LCD_CLEAR );
Lcd_Cmd( _LCD_CURSOR_OFF );
}
void writeToLcd( int inc ) {
IntToStr(inc, kk);
Lcd_Out( 2, 14, Ltrim(kk) );
}
**********************************************************************************
Berminat???
--> pm or wassap..0139473758
--> pm or wassap..0139473758
--> pm or wassap..0139473758
--> pm or wassap..0139473758
--> pm or wassap..0139473758
cepat2 hubungi kami sekarang!!!
**********************************************************************************