About how to use 74HC595 to control the Seven-segment display

Working code to control 6 LEDs. First bitd in bytes are counting from left to right, starting from 0, so if you want to power the first LED ( Q0 on shift register ) , you need this byte: 00000001 ( hex 0x01 ), to power the second led : 00000010 ( hex 0x02 ) , to power the first and second : 00000011 ( 0x03 ). Code ported from Arduino
`
storageClockInput <- hardware.pin1; // pinn 1 of shift register
shiftClockInput <- hardware.pin2; // pinn 11 of shift register
serialIn <- hardware.pin5; // pinn 14 of shift register
data <- 0x03;

storageClockInput.configure(DIGITAL_OUT,0);
shiftClockInput.configure(DIGITAL_OUT,0);
serialIn.configure(DIGITAL_OUT,0);
//
imp.wakeup(2.0, function() {
local i=0;
local pinState;
// hold low for as long as you are transmitting
storageClockInput.write(0);
for( i=7; i>=0; i–) {
shiftClockInput.write(0);
if ( data & (1<<i) ) {
pinState= 1;
}
else {
pinState= 0;
}
server.log("Bits: "+pinState);
//Sets the pin to HIGH or LOW depending on pinState
serialIn.write(pinState);
//register shifts bits on upstroke of clock pin
shiftClockInput.write(1);
// //zero the data pin after shift to prevent bleed through
serialIn.write(0);
}
//stop shifting
shiftClockInput.write(0);
// send to pins/storage
//no longer needs to listen for information
storageClockInput.write(1);
});

`