// Pin definitions:
// The 74HC595 uses a type of serial connection called SPI
// (Serial Peripheral Interface) that requires three pins:
int datapin = 2;
int clockpin = 3;
int latchpin = 4;
// We'll also declare a global variable for the data we're
// sending to the shift register:
byte data = 0;
void send_byte(uint16_t val, uint8_t bits) {
for(uint8_t i = 0; i < bits; i++) {
digitalWrite(datapin, val & (1 << i));
digitalWrite(clockpin, HIGH);
digitalWrite(clockpin, LOW);
}
}
void setup()
{
// Set the three SPI pins to be outputs:
pinMode(datapin, OUTPUT);
pinMode(clockpin, OUTPUT);
pinMode(latchpin, OUTPUT);
digitalWrite(clockpin, LOW);
send_byte(0b010101010, 9);
}
void loop()
{
uint8_t data = 0b10101010;
}