MrDEB
Well-Known Member
WANT TO CONTROL 35 l:edS USING pwm (WANT TO DIM THEN BRIGHTEN DIFFERENT COMBOS)
Basically PWM is turn on then turn off crating a dimming effect.
here is where I started using Swordfish. It kinda works but needs LOTS of work. Using only one led to experiment with.
Basically PWM is turn on then turn off crating a dimming effect.
here is where I started using Swordfish. It kinda works but needs LOTS of work. Using only one led to experiment with.
Code:
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2022 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 1/18/2022 *
* Version : 1.0 *
* Notes : software PWM *
* : *
*****************************************************************************
}
Device = 18F43K22
Clock = 4
// int osc and IO pin libraries
Include "intosc.bas"
#option DIGITALIO_INIT = true // automatically call setalldigital
Include "setdigitalio.bas"
Include "convert.bas"
Dim led1 As PORTC.0
Dim led2 As PORTC.1
Dim LED3 As PORTC.2
Dim LED4 As PORTC.3
Dim cOUNTER As Word
Dim TIME1 As Byte //ON TIME
Dim TIME2 As Byte //OFF TIME
TRISC=0 //ALL OUTPUTS ON PORTC
led1=0
led2=0
LED3=0
LED4=0
TIME1=10
TIME2 = 100
cOUNTER = 255
While TRUE
Toggle(led1)
DelayUS(TIME1)
Toggle (led1)
DelayUS(TIME2 - cOUNTER)
cOUNTER = (cOUNTER - 100)
If cOUNTER = 0 Then
cOUNTER = 255
End If
Wend