Skip to content

Commit

Permalink
Ajout du fichier BASIC/pwm_ctrl.bas
Browse files Browse the repository at this point in the history
  • Loading branch information
Picatout committed Mar 7, 2023
1 parent a772ad4 commit ee232dc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions BASIC/pwm_ctrl.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
NEW
1 PWM.CTRL
5 ' PWM control on channel 2 on D5
10 ' enable PWM control, 10 bits resolution
12 ? "LED control at 244 hertz 16 bits on D5"
20 PWM.EN 1,16 ' 0 to disable
30 'enable channel 2
40 PWM.CH.EN 2,1
50 ADCON 1
60 ' read analog input channel and set TIM1.CCR1 register with value.
70 DO
80 ? "\b\b\b\b\b\b";:LET N=ADCREAD(0)*64: ? n;
90 PWM.OUT 2,N
100 UNTIL KEY? ' quit when a key is pressed
110 ' disable PWM control
120 PWM.CH.EN 2,0 ' disable channel 0
130 PWM.EN 0 ' disable TIMER1
140 END

0 comments on commit ee232dc

Please sign in to comment.