trouble incrementing variable
i having trouble cycling through shift register. i'm looking individual output shift register high when pin 2 on arduino receiving 5v. cycling through pins on 595 each button press. have working initial value once value goes low again stops working. suggestions appreciated. here code:
code: [select]
#include <shifter.h>
#define ser_pin 8 //data
#define rclk_pin 9 //latch
#define srclk_pin 10 //clock
#define num_registers 1
const int buttonpin = 2;
int buttonstate = low;
int n = 0;
shifter shifter(ser_pin, rclk_pin, srclk_pin, num_registers);
void setup(){
}
void loop()
{
shifter.clear();
shifter.write();
buttonstate = digitalread(buttonpin);
if (buttonstate == high)
{
shifter.setpin(n, high);
shifter.write();
delay(150);
n++;
}
}
in setup make buttonpin input.
Arduino Forum > Using Arduino > Programming Questions > trouble incrementing variable
arduino
Comments
Post a Comment