Skip to main content

for

for .. in loop

Loop through each item of an array, or list of values/objects.

Here is an example:

import lib

vcc = supply("VCC")
gnd = dgnd()

at vcc
wire right 100

# Loop through an array of colors
for i in ["yellow", "red", "blue", "green", "purple"]:
add led(i)
wire right 100

add res(10k)

wire right 100 down 100
to gnd

VCC12D1yellow12D2red12D3blue12D4green12D5purple12R110kGND