Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
#define CLOCK 3 #define DATA 2 #define LATCH 4 void setup() { pinMode( CLOCK, OUTPUT ); pinMode( DATA, OUTPUT ); pinMode( LATCH, OUTPUT ); } void display( int n ) { shiftOut( DATA, CLOCK, LSBFIRST, n ); shiftOut( DATA, CLOCK, LSBFIRST, n >> 8 ); digitalWrite( LATCH, HIGH ); digitalWrite( LATCH, LOW ); } void loop() { unsigned int i; for( i = 0x8000; i; i >>= 1 ) { display(i); delay(100); } for( i = 0x0001; i & 0xffff; i <<= 1 ) { display(i); delay(100); } for( i = 0; i < 3; i++ ) { display( 0b1010101010101010 ); delay(1000); display( 0b0101010101010101 ); delay(1000); } for( i = 0; i < 0xffff; i++ ) { display(i); delay(1); } }
This paste will be private.
From the Design Piracy series on my blog: