- Thread starter
- #41
How To Use Progressive Web App aka PWA On 420 Magazine Forum
Note: This feature may not be available in some browsers.
Seems good man, starting to look like something useful!
Love the progress Whiskey. Really cool. Have a Happy New Year and I'll check in when back from vacation and probably see you marketing your new controller, lol.
' Whiskey Papa's Test Program for the 420 Controller
' {$STAMP BS2px}
' {$PBASIC 2.5}
' Pins and Constants
Master PIN 0 ' TBD
F1 PIN 1 ' Button 1
F2 PIN 2 ' Button 2
RedAlert PIN 3 ' will have Red LED and Piezo on it
VExhaust PIN 4 ' Veg Exhaust Fan
FExhaust PIN 5 ' Flower Exhaust
FTempHum PIN 6 ' Flower Area Temp and Humidity
VTempHum PIN 7 ' Veg Area Temp and Humidity
FlowerLights PIN 8 ' Power to Flower Lights
VegLights PIN 9 ' Power to Veg Lights
TimerTrigger PIN 10 ' timer is on pin 10
TimerReset PIN 11 ' timer reset is on pin 11
ACMain PIN 12 ' Power to main Air Conditioner
DayNite1 PIN 13 ' input from Flower TSL Light to Freq Converter
DayNite2 PIN 14 ' input from Veg TSL
CO2Sensor PIN 15 ' input from 15 - CO2 sensor
IsOn CON 0 ' LED is active high
IsOff CON 1
' Variables
isFlowerDay VAR Bit ' Day = 1 , Nite = 0
isVegDay VAR Bit ' Day = 1 , Nite = 0
vegTemp VAR Nib
flowerTemp VAR Nib
vegHum VAR Nib
flowerHum VAR Nib
rValue VAR Word 'reading from RCTIME
rValuePrev VAR Word 'previous value
ppm VAR Word
targetPPM VAR Word
cnt VAR Byte
' **************** Setup Vars ******************
Setup:
' pin# 1111110000000000
' 5432109876543210
CONFIGPIN DIRECTION, %0001111100011000
CONFIGPIN PULLUP, %0001111100001111
CONFIGPIN THRESHOLD, %0111101111000000
CONFIGPIN SCHMITT, %0000000000001111
isFlowerDay = 0
isVegDay = 0
TimerTrigger = IsOff
TimerReset = IsOff
F1 = IsOff
F2 = IsOff
ppm = 390
targetPPM = 1500
' **************** Start Main Program ******************
Main:
'Main Menu
DEBUG CLS,
" WHISKEY PAPA'S 420 CONTROLLER", CR,
" ** MAIN MENU **", CR,
" 1 - Start Timer 2 - Reset Timer ",CR,
" Central Area:",CR,
" A/C On | Temp | Hum |",CR,CR,
" Flower Area:",CR,
" Temp | Hum | CO2 | In | Out | D/N",CR,CR,
" Veg Area:",CR,
" Temp | Hum | CO2 | In | Out | D/N",CR,CR,
" Controller Status:"
DO
IF F1 = 0 THEN GOSUB startTimer
IF F2 = 0 THEN GOSUB resetTimer
' DAY / NITE
DEBUG CRSRXY, 3,13,"Checking Day/Nite"
GOSUB checkLight
DEBUG CRSRXY, 3,14,"Pulse Count: ",DEC cnt," "
IF cnt < 10 THEN
IF daynite1 = 1 THEN GOSUB resetTimer
DEBUG CRSRXY, 3,15, "Nitetime Settings"
isFlowerDay = 0
ELSE
DEBUG CRSRXY, 3,15, "Daytime Settings "
isFlowerDay = 1
ENDIF
' CO2
DEBUG CRSRXY, 30,13,"Checking CO2", CR
GOSUB readPot
ppm = rValue * 2
DEBUG CRSRXY, 30,14,"CO2: ",DEC ppm,"ppm"
IF ppm < targetPPM THEN
IF daynite1 = 1 THEN
DEBUG CRSRXY, 30,15, "Adding CO2 "
GOSUB addCO2
ENDIF
ELSE
DEBUG CRSRXY, 30,15, "No CO2 Needed"
ENDIF
GOSUB updateDebug
LOOP
END
' **************** End Main Program ******************
' Subroutines
readPot:
'reads a variable resistor (such as a potentiometer or
'photoresistor) with RCTIME
'DEBUG CR,"Reading Pot on Pin 15: ", DEC rValue," ...",CR
HIGH CO2Sensor ' set pin high
PAUSE 1
RCTIME CO2Sensor,1,rValue 'read the pin
IF rValue <> rValuePrev THEN 'check if value has changed
'DEBUG "Changed"
rValuePrev = rValue 'record new value
'DEBUG CR, "current value: ",DEC rValue,CR
ENDIF
RETURN
addCO2:
'DEBUG CR, "Starting CO2 Timer"
GOSUB startTimer
RETURN
startTimer:
TimerTrigger = 0
'DEBUG CR,"Timer Started"
PAUSE 5
TimerTrigger = 1
RETURN
resetTimer:
'DEBUG CR, "Timer Reset"
TimerReset = 0
PAUSE 5
TimerReset = 1
RETURN
checkLight:
COUNT DayNite1, 100, cnt 'COUNT on P2 FOR 100 ms, store value in cnt
RETURN
updateDebug:
DEBUG CRSRXY, 3,8,"77.8","F"
DEBUG CRSRXY, 11,8,"49.8","%"
DEBUG CRSRXY, 19,8,DEC ppm,"ppm "
IF isFlowerDay = 1 THEN
DEBUG CRSRXY, 50,8,"Day "
ELSE
DEBUG CRSRXY, 50,8,"Nite"
ENDIF
DEBUG CRSRXY, 3,11,"77.8","F"
DEBUG CRSRXY, 11,11,"49.8","%"
DEBUG CRSRXY, 19,11,DEC (ppm/3),"ppm "
IF isVegDay = 1 THEN
DEBUG CRSRXY, 50,11,"Day "
ELSE
DEBUG CRSRXY, 50,11,"Nite"
ENDIF
Nice grow! And it's going to be even nicer once your controller is finished. I'm definitely in for this one.
Hey WP, I'm really interested in DIY stuff like this, as it is fairly technical... I however have no "micro electronics" knowledge, and i'm quite thrilled to watch it be brought together with growing marijuana in a step by step fashion.
nice stuff!