In order to make our ping pong to work wirelessly, we have decided to use plain old Radio Frequency (RF) Serial Communication. RF transmitters sends bits on pulses of radio energy, and what attracted us to RF frequency is it’s flexibility. RF unlike Infrared serial is omnidirectional and can go greater distances, even through walls. This makes it great for our ping pong application, because as you saw in last week’s Ping Pong video there were lots of acrobatic movements going on. RF is also much easier to program compared to bluetooth. So hopefully we will be able to save more time.
In order to differentiate the signal from ambient radio or light waves, the data is sent on carrier wave. Actual information is encoded by slightly varying the frequency of the carrier wave (FM) or signal strength (AM). We will be using 315MHz.
What we have so far:
Laipac Transmiter & Reciever
.jpg)
The coding that we have so far, but still needs to worked on as we are picking up other signals we don’t want.
inbyte var byte ‘ incoming string
outout portb.1 ‘ status LED
output portc.6 ‘ serial out to PC
input portc.7 ‘ serial in from reciever
n_2400 con 16780 ‘ baud mode for serin2 (2400-8-N-1 inverted)
n_9600 con 16468 ‘ baud mode for serin2 (9600-8-N-1 inverted)
i var byte ‘ loop counter
RFSerialIn var portc.7
PCSerialOut var portc.6
StatusLED var portb.1
‘ flash status LED to start:
high StatusLED
pause 500
lowStatusLED
main:
‘ this serial call does nothing until it gets bytes:
serin2 RFserialIn, n_2400, [DEC inByte]
‘ high statusLED
‘ if the first three bytes are “OBJ”, then
‘ the fourth byte is data. parse it as a number (DEC inbyte (3))
if inbyte > 0 Then
serout2 PCSerialOUT, n-9600, [DEC inbyte, 10, 13]
high StatusLED
‘ PAUSE 500
‘ LOW StatusLED
endif
‘ low StatusLED
goto main