How can I code two Pi Picos to send/receive data accurately to 10 milliseconds a bit using LED/Photodiode pairs? I am trying to send data from one PiPico to another wirelessly. I am on a bit of a time crunch and have unsuccessfully tried getting my photodiode circuit to output the correct voltage swings to use pico's UART pins. There must be a way to to this more simply.
Right now I am using utime.sleep(), and when I blink my LEDs faster than 0.1 seconds a bit, I get an inaccurate byte or two quite often. I am very new to microcontrollers but dont think I should be loosing so much information at 0.01 seconds. I thought it might be that the Pi pico clocks weren't synced at first, but I'd think 0.01s is slow for the clocks to be so out of sync.
Here is my code: Pico Sending Bits through LEDs:
for i in range (0, len(finalBitString)):
if finalBitString[i]=="1":
led(1)
elif finalBitString[i]=="0":
led(0)
utime.sleep(.01)
Receiving Pi Pico:
while True:
utime.sleep(.005) #sample diode every 0.01 seconds
value = SaqDiode.read_u16()*3.3 / 65536
if (bitCutoff <= value): #read saq diode and determine 1 or 0
bit=1
elif (value <= bitCutoff):
bit=0
utime.sleep(.005)