https://www.marcelpost.com/wiki/index.php?title=ATtiny85_shiftout&feed=atom&action=historyATtiny85 shiftout - Revision history2024-03-28T08:22:52ZRevision history for this page on the wikiMediaWiki 1.39.5https://www.marcelpost.com/wiki/index.php?title=ATtiny85_shiftout&diff=657&oldid=prevAdmin at 03:32, 7 February 20122012-02-07T03:32:15Z<p></p>
<p><b>New page</b></p><div>In an attempt to port some code originally written for Arduino I came across a function that doesn't seem to be supported on AVR-GCC. I hope I just haven't found the library yet but in any case, here's some code to produce the same function.<br />
<br />
<pre><br />
#define HIGH 1<br />
#define LOW 0<br />
<br />
void shiftOut(byte dataPin, byte clockPin, byte bitOrder, byte value)<br />
{<br />
<br />
int i;<br />
<br />
for (i = 0; i < 8; i++) <br />
{<br />
<br />
if (bitOrder == LSBFIRST) <br />
{<br />
digitalWrite(dataPin, !!(value & (1 << i)));<br />
} else {<br />
digitalWrite(dataPin, !!(value & (1 << (7 - i))));<br />
}<br />
<br />
digitalWrite(clockPin, HIGH);<br />
digitalWrite(clockPin, LOW);<br />
<br />
}<br />
<br />
} <br />
</pre><br />
<br />
See also: <br />
<br />
http://arduino.cc/en/Reference/ShiftOut<br />
<br />
[[C and C++]]</div>Admin