Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //**************************************************************//
- // Name : shiftOutCode, Hello World: The Remake //
- // : From BYTE to INT and back again //
- //****************************************************************
- // Pin connected to ST_CP of 74HC595
- int latchPin = 8;
- // Pin connected to SH_CP of 74HC595
- int clockPin = 12;
- // Pin connected to DS of 74HC595
- int dataPin = 11;
- void setup() {
- // set pins to output because they are addressed in the main loop
- pinMode(latchPin, OUTPUT);
- pinMode(clockPin, OUTPUT);
- pinMode(dataPin, OUTPUT);
- }
- void loop() {
- apply( B11111111, B00000000, 500 );
- apply( B00000000, B11111111, 500 );
- }
- // to apply a value to the chip
- void apply( byte first_pin_val, byte second_pin_val, int wait ) {
- digitalWrite(latchPin, LOW); // first turn off the latch
- shiftOut( dataPin, clockPin, LSBFIRST, int(first_pin_val) );
- shiftOut( dataPin, clockPin, LSBFIRST, int(second_pin_val) );
- digitalWrite(latchPin, HIGH); // turn on the latch, to prevent more writing.
- delay( wait ); // and wait until we start again.
- }
Add Comment
Please, Sign In to add comment