Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

sbit LCD_RS at RD2_bit;

sbit LCD_EN at RD3_bit;


sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;

// Pin direction
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
short duty1 = 255;

char Isworking(){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1, "is working");
}

void main() {

Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_CLEAR);
get_number();

TRISD = 0x00; //PORTD as input


TRISC = 0xff; //PORTC as output
TRISB = 0x00; //PORTB as output
PWM1_Init(5000); //Initialize PWM1
PWM1_Start(); //start PWM1
//Set current duty for PWM1
while (1) // endless loop
{
if (PORTC.F3==1) //Checking the button pressed or not
{
PORTC.B0= 0B1;
Delay_ms(2);
duty1=255; // increment duty cycle
PWM1_Set_Duty(duty1); //Change the duty cycle
Lcd_Cmd(_LCD_CLEAR);
Isworking();
}
STOP();
}
}
}

You might also like