void setup()
{
- for (int i = 0; i < 4; ++i)
+ for (uint8_t i = 0; i < (sizeof(shreg_pins)/sizeof(shreg_pins[0])); ++i){
pinMode(shreg_pins[i], OUTPUT);
+ }
+
digitalWrite(shreg_stcp_pin, LOW);
digitalWrite(shreg_shcp_pin, LOW);
}
void shreg_write(uint8_t data) {
- for (int i = 0; i < 8; ++i) {
+ for (uint8_t i = 0; i < 8; ++i) {
digitalWrite(shreg_shcp_pin, LOW);
- delay(10);
- unsigned val = data & (0x80 >> i);
+ uint8_t val = data & (0x80 >> i);
digitalWrite(shreg_input_pin, val > 0);
digitalWrite(shreg_shcp_pin, HIGH);
- delay(10);
}
digitalWrite(shreg_shcp_pin, LOW);
digitalWrite(shreg_stcp_pin, HIGH);
- delay(10);
digitalWrite(shreg_stcp_pin, LOW);
}
void loop()
{
- for (int i = 0; i < 8; ++i) {
+ for (uint8_t i = 0; i < 8; ++i) {
shreg_write(1 << i);
delay(500);
}