Turn on and off the LEDs bitwise

Learn:

  • Digital Output
  • LED

The Light Application Adaptor has a Red, Yellow, Green LED and switch connected as shown

WriteBit.py

import emant import time m = emant.Emant300() m.Open("00:06:66:00:a1:D8") print m.HwId() m.ConfigDIO(0x08) count = 0 while count < 3: m.WriteDigitalBit(count,False) count += 1 time.sleep(1) m.Close()

Code Explained

m.ConfigDIO(0x08)

For hex 0x08 or binary 00001000 where

  • 1 indicates bit is input
  • 0 indicates bit is output
Therefore D3 is configured as input and the rest of the bits are outputs. This is also the default - therefore the line is redundant. However this line is necessary if your DIO configuration is different from the default

m.WriteDigitalBit(count,False)

Set the count to the LED bit assignment and the state to True to turn off and False to turn on the LED.

On power up or on DAQ module reset, the digital outputs are set to True

If you are using the emant driver version earlier than 0.8.1, download files using the Test380 app. When you run the diagnostic.py you are shown the version. 0.8.1 fixes a configDIO bug.

Python with EMANT380
| TOC | 1 | 2 | 3 | 4 | 5 | 6 |