Skip to main content

for

for .. in loop

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

Here is an example:

from std import *

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) pin 2
wire right 100

add res(10k)

wire right 100 down 100
to gnd
VCC12D1_1yellow12D1_2red12D1_3blue12D1_4green12D1_5purple12R110kGND