Shop OBEX P1 Docs P2 Docs Learn Events
making the leds light up while receiving data — Parallax Forums

making the leds light up while receiving data

niconico Posts: 28
edited 2010-01-20 07:38 in BASIC Stamp
hi,

I am receiving data from·the parallax·Receiver (#27981) using the following code given in the datasheet i am only able to make the LEDS blink when receiving data.
DO
LOW 0
SERIN 7, 16468, [noparse][[/noparse]WAIT("!"), x.HIGHBYTE, x.LOWBYTE, y.HIGHBYTE, y.LOWBYTE]
HIGH 0
DEBUG ? x
DEBUG ? y

LOOP


However, I want to make 1 LED to light out when not recieving data and the other 1 LED light up when receiving data. 1 LED on at a time. I am not able to do it. Is there any command or codes I can use to detect whether my reciever is recieving data or not ?

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2010-01-19 12:57
    The BS2 is a single-tasking processor. You COULD get this effect by turning ON the "not recieving" LED, then doing the SERIN. If the SERIN returns with data, turn OFF the "not recieving" LED and ON the "recieving" LED.

    The problem with this approach is you're not really indicating when exactly you're recieving data -- more like "checking for data", and "Data recieved". But usually that's enough for most people.
  • niconico Posts: 28
    edited 2010-01-20 03:07
    yes that is what i try at first. but it end up with blinking effect. because of the do loop
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2010-01-20 03:47
    Where are leds connected? I see a reference to pin p0 -- is that the led? You could attach an led+resistor between pin p7 and Vss, and that would flicker when data is being received, best results with a high intensity LED. I reread what you wrote, and I feel that I don't understand what you are asking.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • MoskogMoskog Posts: 554
    edited 2010-01-20 07:38
    In your program the LED, if it is connected to pin 0, will blink between receiving data, while writing to the debug screen.
    What about putting in an error-check after the SERIN-line, something you will probably need anyway later, and if you are receiving correct data then light another LED for half a second or so before going back to the loop.
    This way the other LED will not actually lit when receiving is going on but lit half a second every time received true information.
Sign In or Register to comment.