MrDEB
Well-Known Member
we have a winner I hope
Got this from DIY (Thanks to Lightspeed) but it works on my test pcb.
Now just combine the candle LED code and this code together and hope
I need to figure out how to enable the B ports using the output from the ADC. This code does it but will it work with my candle code?
NOTE a new pak of modules for SF Swordfish User Module Pack
Got this from DIY (Thanks to Lightspeed) but it works on my test pcb.
Now just combine the candle LED code and this code together and hope
I need to figure out how to enable the B ports using the output from the ADC. This code does it but will it work with my candle code?
NOTE a new pak of modules for SF Swordfish User Module Pack
Code:
Device = 18F1320
Clock = 8
#option AD_RESIST = 800000
Include "InternalOscillator.bas"
Include "ADC.bas"
Include "MinADtime.bas"
Dim LED0 As PORTB.0, LED1 As PORTB.1, LED2 As PORTB.2, LED3 As PORTB.3
Const DarkVal = 512
Function Get_ADC_Sample() As Word // Function to grab the ADC sample
Result = ADC.Read(0) // Grab an ADC sample from channel 0
End Function
ADCON1.0 = 0 // Configure AN0 as analogue
While True // Create an infinite loop
If Get_ADC_Sample > DarkVal Then // Monitor for change
High(LED0)
High(LED1)
High(LED2)
High(LED3)
Else
Low(LED0)
Low(LED1)
Low(LED2)
Low(LED3)
EndIf
Wend