Digital I/O Demo 2 -- Generating digital output ================================================================================== In this demo, we get the number of TTL/digital outs available on the device: ``nBits = Datapixx('GetDoutNumBits');``. To figure out how to talk to one of these ``nBits`` TTL, we need to describe this in binary. If ``nBits`` is for example 16, we will have access to 16 TTL and each of them are represented with a power of 2. ``2^0`` is going to be output zero, ``2^1`` is output one. Keeping up with this example of 16 TTL, we can represent this in binary: ``0b0000 0000 0000 0000``, where every 0 represents a 2 to a power and a digital out. To set all of them on, we do ``Datapixx('SetDoutValues', (2^nBits) - 1);``. ``2^nBits`` would be ``0b1 0000 0000 0000 0000``, if we remove one from that, we get ``0b1111 1111 1111 1111``, therefore setting all of them on (this example is again for ``nBits = 16``). .. literalinclude:: ../DatapixxToolbox/DatapixxDemos/DatapixxDoutBasicDemo.m :language: matlab :emphasize-lines: 26, 31, 36, 41 :linenos: