# share my UART receive code

**URL:** <https://forums.openmv.io/t/share-my-uart-receive-code/495>\
**Category:** OpenMV Boards\
**Created:** [November 21, 2017, 11:01pm UTC](https://forums.openmv.io/t/share-my-uart-receive-code/495 "2017-11-21T23:01:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![laiyingjie](https://avatars.discourse-cdn.com/v4/letter/l/aca169/32.png) [@laiyingjie](https://forums.openmv.io/u/laiyingjie)\
**Post date:** [November 21, 2017, 11:01pm UTC](https://forums.openmv.io/t/share-my-uart-receive-code/495/1 "2017-11-21T23:01:39Z")

</div>

global\_list.py:

```python
buf = bytearray(30)

```

main.py:

```python
import global_list
import sensor
import time, sensor, pyb
from pyb import UART
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames()
uart = UART(3, 9600)
led = pyb.LED(3)
clock = time.clock()
while(True):
    clock.tick()
    img = sensor.snapshot()
    print(clock.fps())
    if (uart.any()):
        uart.readinto(global_list.buf)
        print(global_list.buf)
        if global_list.buf[0] == 0xAA:
            led.on()
        if global_list.buf[1] == 0xAB:
            led.off()

```
