Skip to content

Commit f2429a7

Browse files
committed
Script node gpio docs added example
1 parent a09aa34 commit f2429a7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/source/components/nodes/script.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,24 @@ In the script node you can interface with GPIOs of the VPU using module GPIO. Cu
120120
GPIO.PullDownUp: GPIO.PULL_NONE, GPIO.PULL_DOWN, GPIO.PULL_UP
121121
GPIO.Edge: GPIO.RISING, GPIO.FALLING, GPIO.LEVEL_HIGH, GPIO.LEVEL_LOW
122122
123+
Here's **an example** of toggling GPIO pin 40 inside Script node from the host (via :ref:`XLinkIn``). On `OAK-SoM-Pro <https://docs.luxonis.com/projects/hardware/en/latest/pages/BW2099.html>`__,
124+
GPIO 40 drives FSYNC signal for both 4-lane cameras, and we have used the code below for this exact reason.
125+
126+
.. code-bloc:: python
127+
128+
import GPIO
129+
MX_PIN = 40
130+
131+
ret = GPIO.setup(MX_PIN, GPIO.OUT, GPIO.PULL_DOWN)
132+
toggleVal = True
133+
134+
while True:
135+
data = node.io['in'].get() # Wait for a message from the host computer
136+
137+
node.warn('GPIO toggle: ' + str(toggleVal))
138+
toggleVal = not toggleVal
139+
ret = GPIO.write(MX_PIN, toggleVal) # Toggle the GPIO
140+
123141
Using DepthAI :ref:`Messages <components_messages>`
124142
###################################################
125143

0 commit comments

Comments
 (0)