Hello I have a PIC 12F675 and I'm using great cow basic and I wrote a program that turns a fan on and off and I want to use a PNP transistor to act as a switch, but I need a pin to act as a ground so it works.
But for the life of me I can't figure out how to set it as a ground in Great Cow Basic.
I'm trying set GPIO 0 as ground.
Here is the code in GCBASIC:
If you perfer assembly language let me know and I'll post it on a copy and paste website, I'm in a rush atm.
Thank you!
But for the life of me I can't figure out how to set it as a ground in Great Cow Basic.
I'm trying set GPIO 0 as ground.
Here is the code in GCBASIC:
Rich (BB code):
;Chip Settings
#chip 12F675,0
#config MCLRE=OFF, WDT=OFF
;Variables
Dim byOffDelay As integer
Dim byOnDelay As integer
Dim OutputVar As byte
Dim CountStartTimer As integer
byOffDelay = 1000
byOnDelay = 1000
CountStartTimer = 0
Dir GPIO.0 Out
Dir GPIO.1 In
Dir GPIO.2 In
Dir GPIO.4 In
Set GPIO.0 On
Goto DelayOff
DelayOn:
Repeat byOnDelay
Pot GPIO.4, OutputVar
Wait 1 ms
If GPIO.1 = On Then
Else
CountStartTimer = CountStartTimer + 1
If CountStartTimer >= 300 Then
CountStartTimer = 0
Set GPIO.0 On
Goto DelayOff
End If
byOffDelay = 1000 * [integer]OutputVar
End If
If GPIO.2 = On Then
Else
byOnDelay = 1000 * [integer]OutputVar
End If
End Repeat
Set GPIO.0 On
Goto DelayOff
DelayOff:
Repeat byOffDelay
Pot GPIO.4, OutputVar
Wait 1 ms
If GPIO.1 = On Then
CountStartTimer = 0
Else
CountStartTimer = CountStartTimer + 1
byOffDelay = 1000 * [integer]OutputVar
End If
If GPIO.2 = On Then
Else
byOnDelay = 1000 * [integer]OutputVar
End If
End Repeat
Set GPIO.0 Off
Goto DelayOn
Thank you!