From ee232dce73b9353f656dd061c797993363c2b8cd Mon Sep 17 00:00:00 2001 From: Jacques Date: Tue, 7 Mar 2023 14:51:16 -0500 Subject: [PATCH] Ajout du fichier BASIC/pwm_ctrl.bas --- BASIC/pwm_ctrl.bas | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 BASIC/pwm_ctrl.bas diff --git a/BASIC/pwm_ctrl.bas b/BASIC/pwm_ctrl.bas new file mode 100644 index 0000000..64eee8d --- /dev/null +++ b/BASIC/pwm_ctrl.bas @@ -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 +