This is a little project I built for a friend of mine.
He services mopeds and does alot of custom work for his clients.
You can see some of his work at Meka Scoot Tuning, he is a talented mechanic and body work guy.
Long story short: he requested a small board he wanted to put on one of the mopeds, this is the device I came up with.
See the code in action on Tinkercad
int SERPin = 1; //OUTPUT
int RCLKPin = 3; //REFRESH
int SRCLKPin = 4; //CLOCK
int SPEED = 100; //millis
#define NumLEDs 16
int LED = NumLEDs - 1;
bool Right = false;
void setup() {
pinMode(SERPin, OUTPUT);
pinMode(RCLKPin, OUTPUT);
pinMode(SRCLKPin, OUTPUT);
}
void loop() {
for(int i = 0; i < NumLEDs; i++){
if(i == LED) {
storedState(1);
}
else {
storedState(0);
}
}
if(Right) {
LED++;
if(LED > NumLEDs - 1) {
Right = false;
LED = 15;
}
}
else {
LED--;
if(LED < 0) {
Right = true;
LED = 0;
}
}
digitalWrite(RCLKPin, HIGH);
digitalWrite(RCLKPin, LOW);
delay(SPEED);
}
void storedState(int State) {
digitalWrite(SERPin, LOW);
if(State) {
digitalWrite(SERPin, HIGH);
}
digitalWrite(SRCLKPin, HIGH);
digitalWrite(SRCLKPin, LOW);
digitalWrite(SERPin, LOW);
}
