hi
im new user in this forum.And my english is not good.I hope you can understand me.
ı use the 16f877 and this code:TRISA = %00001011
trisb=1
portb=0
' Allocate variables
x var byte
y var byte
z var byte
ADCON1 = 4 ' Set PortA 0, 1, 3 to A/D inputs
Low PORTE.2 ' LCD R/W line low (W)
Pause 100 ' Wait for LCD to start
Goto mainloop ' Skip subroutines
' Subroutine to read a/d converter
getad:
Pauseus 50 ' Wait for channel to setup
ADCON0.2 = 1 ' Start conversion
Pauseus 50 ' Wait for conversion
Return
' Subroutine to get pot x value
getx:
ADCON0 = $41 ' Set A/D to Fosc/8, Channel 0, On
Gosub getad
x = ADRESH
Return
' Subroutine to get pot y value
gety:
ADCON0 = $49 ' Set A/D to Fosc/8, Channel 1, On
Gosub getad
y = ADRESH
Return
' Subroutine to get pot z value
getz:
ADCON0 = $59 ' Set A/D to Fosc/8, Channel 3, On
Gosub getad
z = ADRESH
Return
mainloop:
Gosub getx ' Get x value
Gosub gety ' Get y value
Gosub getz ' Get z value
pwm portb.0,x,1
pwm portb.1,y,1
pwm portb.2,z,1
Goto mainloop ' Do it forever
End
ı connect the 3 led from the portb.0 portb.1 and portb.2
its working but its not come to 0v.All led is not come to off.This problem is burn to code or hardware please help me
thx
Bookmarks