-serin -> serout easy coding help needed

Hi

i need a segment of code that will allow my 40X2 to respond to a serial input from another pic for example "244" and then output that same number to a position on a 20 x 4 OLED screen my only problem is the "bit in the middle" the transition stage between serin, and serout, ive tried equalling a given variable e.g. B0 to the serin value but i cant work out how i then get the value of that variable to work with the serout command, i tried simply putting the B0 after the baudmode in the serout command but i kept getting syntax errors,

all that should happen at the end is that the 40x2 will receive a number (representing your current speed) which i will then be output on a given position on the OLED screen (if you should post a snippet of code, the position is your choice)

any useful information will be greatly appriciated

kind regards
Sean
 

PaulRB

Senior Member
Sean, post the code you have described. I'm sure someone will spot what you're doing wrong, or not doing!

Paul
 

hippy

Ex-Staff (retired)
all that should happen at the end is that the 40x2 will receive a number (representing your current speed) which i will then be output on a given position on the OLED screen
It's perhaps more difficult than if first seems. Two questions to start with -

1) How does the 40X2 know where one number ends and where another number begins ?

2) Do you have any control over what is sent to the 40X2 ?
 
1) i have no idea, this is kind of what i could do with a little help with

2) yes :) at the moment im using a 28X2 and matching project board to generate a serial output, if that's of any use

and yes, it undoubtedly is, usually more difficult that initally anticipated :)
 

hippy

Ex-Staff (retired)
In the sender you could use ...

w9 = 12345
SerOut pin, baud, ( "[", #w9 , "]" )

Then in the receiver use ...

SerIn pin, baud, ( "[" ), #w1

Whatever was sent will now be placed in 'w1' and you can do whatever you want with that data.
 

hippy

Ex-Staff (retired)
Perhaps post your full code, sender and receiver, and indicate what you are simulating. This works for me ...

Code:
w9 = 12345
Do
  SerOut C.2, N2400, ( "[", #w9, "]" )
  Pause 1000
  w9 = w9 + 1
Loop
Code:
Do
  SerIn C.1, N2400, ( "[" ), #w1
  SerTxd( "Got=", #w1, CR, LF )
Loop
 
Top