Const Pca9685adw =&H82 ' Write Adress (A0 to VCC and A1-A5 to gnd ) Const Pca9685m1 =&H00 ' Register Adress Mode 1 Const Pca9685m2 =&H01 ' Register Adress Mode 2 Const Led0 =&H06 ' Register adress LED0 next +4 Const Speedfront =250' Define waitms before next led front or left Const Speedback =100' Define waitms before next led back or right Const Minpower =0' Define minimum power to star led light Const Maxpower =4095' define max power Const Boostspeed =9' reduce the step 4096 is big
Dim A AsByte Dim Temp AsByte Dim Temp2 AsByte Dim Z AsWord Dim Inv AsWord Dim Pwml AsByte Dim Pwmh AsByte Dim First AsBit
' Reset device I2cinit I2cstart I2cwbyte Pca9685adw
I2cwbyte Pca9685m1
I2cwbyte&H01
I2cstop Waitms10 ' Set MODE 1 I2cstart I2cwbyte Pca9685adw
I2cwbyte Pca9685m1
I2cwbyte&H81 ' PCA Responds to Led All Call and Restart enabled I2cwbyte&HA1 ' enable auto increment I2cstop ' Set MODE 2 I2cstart I2cwbyte Pca9685adw
I2cwbyte Pca9685m2
I2cwbyte&H10 ' Set the output pin mode (direct to led) I2cstop ' ALL LED OFF For A =0To15
Temp =4* A
Temp = Temp + Led0
I2cstart I2cwbyte Pca9685adw
I2cwbyte Temp
I2cwbyte&H00
I2cwbyte&H00
I2cwbyte&H00
I2cwbyte&H00
I2cstop Next
First =1 Do For A =0To15Step1
Temp =4* A
Temp = Temp + Led0
Temp2 = Temp -4 For Z = Minpower To Maxpower Step Boostspeed
If First =1Or A >0Then
Pwml =Low(z)
Pwmh =High(z) I2cstart I2cwbyte Pca9685adw
I2cwbyte Temp
I2cwbyte&H00
I2cwbyte&H00
I2cwbyte Pwml
I2cwbyte Pwmh
I2cstop End If If A >0Then
Inv = Maxpower - Z
Pwml =Low(inv)
Pwmh =High(inv) I2cstart I2cwbyte Pca9685adw
I2cwbyte Temp2
I2cwbyte&H00
I2cwbyte&H00
I2cwbyte Pwml
I2cwbyte Pwmh
I2cstop End If Next
Waitms Speedfront
Next
First =0 For A =15To0Step-1
Temp =4* A
Temp = Temp + Led0
Temp2 = Temp -4 For Z = Minpower To Maxpower Step Boostspeed
If A >0Then
Inv = Maxpower - Z
Pwml =Low(inv)
Pwmh =High(inv) I2cstart I2cwbyte Pca9685adw
I2cwbyte Temp
I2cwbyte&H00
I2cwbyte&H00
I2cwbyte Pwml
I2cwbyte Pwmh
I2cstop End If
Pwml =Low(z)
Pwmh =High(z) I2cstart I2cwbyte Pca9685adw
I2cwbyte Temp2
I2cwbyte&H00
I2cwbyte&H00
I2cwbyte Pwml
I2cwbyte Pwmh
I2cstop Next Waitms Speedback
Next Loop End
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum