I have written a GCB script to run two separate routines on my breadboard, I am not sure if GCB is able to do this, but essentially I have a Red, Green, Yellow & Blue LED's. I would like the Red, Green and Yellow to run as input to output (i.e. SetWith). The Yellow is shared between the two routines. The Yellow and Blue are to run as 'Select Case' based upon the ADCValue. The code doesn't seem to work and I suspect I am missing a small (yet VERY essential) link between trying to run the to commands/routines. I have pasted my code below and would appreciate any feedback. Thanks in advance guys.
chip 16f1823
option Explicit
#define RIN RA2
#define GIN RA0
#define YIN RA4
#define BIN RA1
#define ROU RC4
#define GOU RC1
#define YOU RC3
#define BOU RC2
Dir ROU out
Dir GOU out
Dir YOU out
Dir BOU out
Dir RIN in
Dir GIN in
Dir YIN in
Dir BIN in
'-----MAIN BODY OF PROGRAM COMMENCES HERE.,
Do Forever
Your first loop is do Forever so the second loop will never run.
Combine them both into one loop and see if that helps.
chip16f1823optionExplicit
#defineRINRA2
#defineGINRA0
#defineYINRA4
#defineBINRA1
#defineROURC4
#defineGOURC1
#defineYOURC3
#defineBOURC2DirROUoutDirGOUoutDirYOUoutDirBOUoutDirRINinDirGINinDirYINinDirBINin'-----MAIN BODY OF PROGRAM COMMENCES HERE.,Dim ADCValue as ByteDo ForeverADCValue = ReadAD( AN1 )Select Case ADCValue case 0 to 34 YOU = 0 BOU = 0 case 35 to 178 YOU = 1 BOU = 0 case 179 to 255 YOU = 0 BOU = 1end selectSetWith ( ROU, RIN )SetWith ( GOU, GIN )SetWith ( YOU, YIN )wait 100 msLoop
The above is untested, it is just a suggested structure for your code.
Last edit: Chris Roper 2020-05-28
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
I have written a GCB script to run two separate routines on my breadboard, I am not sure if GCB is able to do this, but essentially I have a Red, Green, Yellow & Blue LED's. I would like the Red, Green and Yellow to run as input to output (i.e. SetWith). The Yellow is shared between the two routines. The Yellow and Blue are to run as 'Select Case' based upon the ADCValue. The code doesn't seem to work and I suspect I am missing a small (yet VERY essential) link between trying to run the to commands/routines. I have pasted my code below and would appreciate any feedback. Thanks in advance guys.
chip 16f1823
option Explicit
#define RIN RA2
#define GIN RA0
#define YIN RA4
#define BIN RA1
#define ROU RC4
#define GOU RC1
#define YOU RC3
#define BOU RC2
Dir ROU out
Dir GOU out
Dir YOU out
Dir BOU out
Dir RIN in
Dir GIN in
Dir YIN in
Dir BIN in
'-----MAIN BODY OF PROGRAM COMMENCES HERE.,
Do Forever
SetWith ( ROU, RIN )
SetWith ( GOU, GIN )
SetWith ( YOU, YIN )
Loop
Dim ADCValue as Byte
Do Forever
Your first loop is do Forever so the second loop will never run.
Combine them both into one loop and see if that helps.
The above is untested, it is just a suggested structure for your code.
Last edit: Chris Roper 2020-05-28