Blinking LED using Box0

Electrical Connections

Electrical Connections

Julia Code

In [ ]:
import Box0

# open the device (Box0 USB open a supported device)
dev = Box0.Usb.open_supported()

# open DIO (digital Input/Output) module
dio = Box0.dio(dev)

# Prepare for basic operations (read, write, toggle etc..)
Box0.basic_prepare(dio)

# initalize the pin
pin0 = Box0.pin(dio, 0)
Box0.output(pin0)
Box0.low(pin0)
Box0.enable(pin0)

# Start basic mode (things will come into effect)
Box0.basic_start(dio)

#TODO: catch SIGINT (InterruptException)
# not working: http://stackoverflow.com/questions/20831290
# if not caught, module is not closed, it will require kernel restart
while true
    Box0.toggle(pin0)
    sleep(.5)
end

# Stop in basic mode
Box0.basic_stop(dio)

Box0.close(dio)
Box0.close(dev)