# Sending Triggers via UDP

**URL:** <https://discourse.psychopy.org/t/sending-triggers-via-udp/42711>\
**Category:** Coding\
**Created:** [October 29, 2024, 1:35pm UTC](https://discourse.psychopy.org/t/sending-triggers-via-udp/42711 "2024-10-29T13:35:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Lechner](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/alexander_lechner/32/43085_2.png) [@Alexander\_Lechner](https://discourse.psychopy.org/u/Alexander_Lechner)\
**Post date:** [October 29, 2024, 1:35pm UTC](https://discourse.psychopy.org/t/sending-triggers-via-udp/42711/1 "2024-10-29T13:35:45Z")

</div>

I use a tool called Unicorn Recorder, which can receive triggers via UDP ([GitHub - unicorn-bi/Unicorn-Recorder-Hybrid-Black: Unicorn Recorder Hybrid Black](https://github.com/unicorn-bi/Unicorn-Recorder-Hybrid-Black?tab=readme-ov-file#receiving-triggers-via-udp)). I am curious, if PsychoPy can send triggers via UDP? I found only the option via LSL, but the Unicorn Recorder has no LSL receiver.  
Thank you.

---

<div class="post-metadata">

**Author:** ![pmolfese](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/pmolfese/32/35899_2.png) [@pmolfese](https://discourse.psychopy.org/u/pmolfese)\
**Post date:** [October 29, 2024, 11:58pm UTC](https://discourse.psychopy.org/t/sending-triggers-via-udp/42711/2 "2024-10-29T23:58:27Z")

</div>

Perhaps an oversimplification: If you can do it in Python, you can probably do it with PsychoPy.

It looks like the software has code for doing python communication on the GitHub page:

```auto
import socket

# Initialize socket
socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
endPoint = ("127.0.0.1", 1000)

# Send trigger
sendBytes = b"1"
socket.sendto(sendBytes, endPoint)

```

You could add a trigger sending to your event loop by adding those bits for sending the trigger into your “each frame” in builder.
