trebase da se izraboti samostoen proekt so PIC, pa megju drugoto izrabotiv i nesto vakvo (ova e nova verzija, prethodnata od proektnata e malku porazlicna)
Sema
[img width=700 height=463]http://pic.mk/images/NJQ03.jpg[/img]
Kod za PIC-ot (µBasic PRO for PIC, mikroe)
Code: Select all
program PWM_DC_Kontrola
dim n as byte
sub procedure InitMain()
CMCON = 7
INTCON = 6
PORTA = 255
TRISA = 255
PORTB = 0
TRISB = 0
PWM1_Init(255)
end sub
main:
InitMain()
n = 15
PWM1_Start()
PWM1_Set_Duty(n)
while (TRUE)
if (Button(PORTA,0,1,1)) then
Delay_ms(40)
Inc(n)
PWM1_Set_Duty(n)
while (RA0_bit <> 0)
nop
wend
end if
if (Button(PORTA,1,1,1)) then
Delay_ms(40)
Dec(n)
PWM1_set_Duty(n)
while (RA1_bit <> 0)
nop
wend
end if
Delay_ms(5)
wend
end.
http://www.youtube.com/watch?v=v5VOzogq-pw