serial input


Author Message
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2940
Posted: 02:01am 10 Jun 2025      

A simple test between 2 PicoMites.
'Pico A GP0 pin1 -------> Pico B GP1 pin2
'       Gnd pin3 -------> Gnd pin3
' Serial Tx test program on Pico A
setpin gp1,gp0, com1 : OPEN "COM1:115200" AS #1
dt$=datetime$(now)
do
  do while datetime$(now) = dt$ : loop 'wait for time to change

  print #1, datetime$(now) 'send it
  dt$ = datetime$(now)  
loop

' Serial Rx test program on Pico B
SetPin gp1,gp0, com1 : Open "COM1:115200" As #1
g$ = Input$(255,#1) : g$="" 'purge the Rx buffer
Do
 Do While Loc(#1) = 0 : Loop 'wait for data to start arriving

 Pause 2 'allow time for the rest if the message to arrive
         'increase for longer message or lower baud rate
 Print Loc(#1); " Bytes in Rx buffer",
 g$ = Input$(255,#1)
 Print g$;
Loop

Output
> RUN
21 Bytes in Rx buffer  10-06-2025 13:05:37
21 Bytes in Rx buffer  10-06-2025 13:05:38
21 Bytes in Rx buffer  10-06-2025 13:05:39
21 Bytes in Rx buffer  10-06-2025 13:05:40
21 Bytes in Rx buffer  10-06-2025 13:05:41
21 Bytes in Rx buffer  10-06-2025 13:05:42
21 Bytes in Rx buffer  10-06-2025 13:05:43
>

Edited 2025-06-10 13:08 by phil99