Log in

View Full Version : Still Experimenting



tazntex
- 23rd July 2008, 14:29
Is there any way when I send my data to the receiver I need it recognize that I am still pressing the switch and hold an output high but once the switch is released the output is to go low? Here is my receiver code:

Serial receiver
INCLUDE "bs2defs.bas"
@ DEVICE PIC16F628a,XT_OSC
@ DEVICE pic16F628a, WDT_OFF ' Watchdog Timer
@ DEVICE pic16F628a, PWRT_ON ' Power-On Timer
@ DEVICE pic16F628a, MCLR_ON ' Master Clear Options (Internal)
@ DEVICE pic16F628a, BOD_ON ' Brown-Out Detect
@ DEVICE pic16F628a, LVP_OFF ' Low-Voltage Programming
@ DEVICE pic16F628a, CPD_OFF ' Data Memory Code Protect
@ DEVICE pic16F628a, PROTECT_OFF
DEFINE OSC 4
mydata var byte
serpin var porta.1
dgood var porta.2
porta=0
portb=0
trisa = %00000010
trisb = %00000000
CMCON=7
PAUSE 50

loop:
gosub loop1
if mydata > 0 then dgood=1
if mydata = 0 then dgood=0
if mydata =%01010110 then rly1
if mydata <>%01010110 then low 7

if mydata =%01011001 then rly2
if mydata <>%01011001 then Low 6

if mydata =%01011010 then rly3
if mydata <>%01011010 then low 5

if mydata =%01100101 then rly4
if mydata <>%01100101 then low 4

if mydata =%01100110 then rly5
if mydata <>%01100110 then low 3

if mydata =%01101001 then rly6
if mydata =%01101010 then rly7
if mydata =%10010101 then rly8
goto loop
rly1:
high 7
pause 100
goto loop
rly2:
HIGH 6
pause 100
goto loop
rly3:
HIGH 5
pause 100
goto loop
rly4:
HIGH 4
pause 100
goto loop
rly5:
HIGH 3
pause 50
goto loop
rly6:
toggle 1
pause 100
goto loop
rly7:
toggle 0
pause 100
goto loop
rly8:
toggle 2
pause 100
goto loop

loop1: SERIN serpin,N2400,[254],mydata
return
End

skimask
- 23rd July 2008, 15:06
Is there any way when I send my data to the receiver I need it recognize that I am still pressing the switch and hold an output high but once the switch is released the output is to go low? Here is my receiver code:
Think yourself thru the code...


If I'm still receiving a code that a switch is pressed, hold the output high and check again
If I'm not receiving the code mentioned above, put the output low and check again

Simple as that...

tazntex
- 24th July 2008, 12:48
Well, I'm about to pull all the hair out of my head. I've tried several things including something like this:
rly1:
if mydata=%00000000 then high 7
pause 250
IF mydata<>%00000000 then low 7
goto loop
Still no go and the next loop:
rly2:
HIGH 6
pause 250
Low 6
goto loop
of course while I pressing the button down on the transmitter rly2 just goes on/off,etc.
I've been going through the compiler manual again trying to figure out what I am missing. Any more tips? Thanks