Tx - Rx with 912MHz
shmow
Posts: 109
' {$STAMP BS2} ' {$PBASIC 2.5} 'transmitter code: - LED (pin 3) is illuminated when button (pin 2 - momentary) is pressed ' and Tx sends value of 1011 with the "XYZ" precursor Btn PIN 2 btnWrk VAR Byte LEDpinOne CON 3 Main: BUTTON Btn, 0, 255, 0, btnWrk, 1, Did_Press LOW LEDpinOne Did_Press: IF btn = 0 THEN HIGH LEDpinOne SEROUT 0, 84, [noparse][[/noparse] "XYZ", DEC 1011 ] PAUSE 10 ENDIF GOTO Main ' {$STAMP BS2} ' {$PBASIC 2.5} 'receiver code: - pin 1 waits for precursor - "XYZ" to assign incoming value - 1011. ' - incoming value is assigned to variable serData ' - first conditional sets pin 15 high if serData equal 1011 - illumiates LED ' - third conditional should "clear" contents of variable serData - with ' debug confirmation ' - second conditional sets pin 15 low when variable serData is "cleared" LEDpin CON 15 SerData VAR Word Main: SERIN 1, 84, [noparse][[/noparse]WAIT("XYZ"), DEC serData] IF serData = 1011 THEN HIGH LEDpin DEBUG DEC serData, CR ENDIF IF serData = 0 THEN LOW LEDpin ENDIF IF serData = 1011 THEN PAUSE 1000 serData = 0 DEBUG DEC serData, CR ENDIF GOTO Main
I've two BOEs each with a transceiver.
One board sends a value when a momentary button is pressed, and the other board turns on an LED when it receives a specific value.
The problem is the LED (on the second board) stays on when the program should turn it off as the valure is "cleared".
I'm not sure why the LED doesn't turn off.··
Any advice?
Thanks,
Johnny Canuck
Comments
Wouldn't the second conditional have switched off the LED?
Shmow
The "second conditional"·is line 7 (yes?):
IF serData = 0 THEN LOW LEDpin -- Therefore, if serData is NOT 0 then the THEN LOW LEDpin will not execute.
IF serData = 1011·in line 3 (that condition is met)·then it would pause for 1 sec, but no matter what value serData, it's made to = 0 in line 12 and the LOW LEDpin in line 13, which I'd added,·executes regardless the value of serData.
Regards,
Shmow