Turn on and off the LEDs Portwise

Learn:

  • Digital Output
  • LED

The difference between this program and the previous one is that the Digital Port is written portwise ie 8 bits at a time.

WritePort.py

import emant import time m = emant.Emant300() m.Open("00:06:66:00:a1:D8") print m.HwId() count = 0 while count < 8: m.WriteDigitalPort(count) count += 1 time.sleep(1) m.Close()

Code Explained

m.WriteDigitalPort(count)

The output bits are determined by the count value
8 – 0000 0111 all LEDs are turned off
7 – 0000 0110 only Green LED is turned on
0 – 0000 0000 all LEDs are turned on