// PIN SETUP
#define PIN_DATA 2
#define PIN_CLOCK 3
#define PIN_LATCH 4
#define schuifPot A0
// PROTOTYPES VD FUNCTIONS
void pinSetup();
void verstuurData();
void resetLijst();
// VARIABLES
byte dataLed [8];
int i ;
int j ;
void setup() {
Serial.begin(115200);
resetLijst();
verstuurData();
pinSetup();
}
void loop() {
//schuifPotWaarde = analogRead(schuifPot);
//schuifPotWaarde = map(schuifPotWaarde, 0, 1023, 1, 8);
//Serial.println(schuifPotWaarde);
for (byte i = 0; i < 8; i++); {
dataLed[i] = ! dataLed[i];
verstuurData();
}
}
// SETUP FUNCTIES
void pinSetup() {
pinMode(PIN_DATA, OUTPUT);
pinMode(PIN_CLOCK, OUTPUT);
pinMode(PIN_LATCH, OUTPUT);
pinMode(schuifPot, INPUT);
}
void verstuurData()
{
delay(map(analogRead(schuifPot), 0, 1024, 50, 200));
digitalWrite(PIN_LATCH, LOW);
for ( int i = 0; i < 8; i++) {
digitalWrite(PIN_DATA, dataLed[i]); // 0 of 1
digitalWrite(PIN_CLOCK, HIGH);
delay(1); // misschien in micro seconden vb 20
digitalWrite(PIN_CLOCK, LOW);
delay(1);
}
digitalWrite(PIN_LATCH, HIGH);
}
void resetLijst(bool waarde) {
for ( int j = 0; j < 8 ; j++) {
dataLed[i] = waarde;
}
}