For interfacing to LCD, look under the help menu in the LCD part. Details are given there.
Say, if you have a variable that stores the value of the duty cycle(255 for 100%, 0 for 0%, 128 for 50%), this is in 8-bit "byte" or "char" data format.
To send this to LCD, you have to convert this to string using this:
Code:
dim txtDuty as string[3]
dim Duty as byte 'Holds duty cycle
dim Duty16 as word
Duty16 = (Duty * 100) >> 8
Duty = Duty16
ByteToStr(Duty, txtDuty) 'Converts byte to string and stores in txtDuty
LCD_Out(R, C, txtDuty) 'Replace R by desired row no and C by desired column no
'On LCD, a value on a scale of 100 will be shown
For initialization of LCD, it depends on compiler version. This is available in the help menu.
Can any one help me?
I got a servo motor,16f877a,20MHz xtal,PICC compiler,I have a burner for my PIC and I use C when writing a program. I got a 5k pot connected to pin A0 and I am planning to use port D to control the servo to go left and right when I turn the pot. The problem is I don't know how to start .... I really wanted to learn more about the MCU and I tried blinking LEDs an and using push buttons before, I hope that someone can help me with complete codes, Thanks in advance!!
Hi Tahmid..hope you notice this reply,
can you help me correct the programming below.ican't compile it..it is from earlier that i want to make variable duty cycle..hope you will help..thanks in advance
program 1
x var byte
TRISC.2 = 0 ' CCP1 (PortC.2 = Output)
PR2 = 110 ' Set PWM Period for approximately 45KHz
CCPR1L = 55 ' Set PWM Duty-Cycle to 50%
CCP1CON = %00001100 ' Select PWM Mode
T2CON = %00000100 ' Timer2 = ON + 1:1 prescale
Main:
if PortA.0=0 then wait0
Pause 500
if PortA.0=1 then wait1
Goto Main
wait0:
CCPR1L=0' reset PWM duty cycle
end
wait1:
CCPR1L=x+6' increase PWM duty cycle by 20% each time the push button is press
end.
Added after 7 minutes:
i mean that each time the push button is press or active low,,,it will reset the duty cycle..and when the push button is release the duty cycle will increase 5 percent up to 80% duty cycle..then if the push button is press again after 80% ,the duty cycle will back to 50% and this process will go on.