Skip to content

Instantly share code, notes, and snippets.

@blooser
Last active July 30, 2018 19:50
Show Gist options
  • Save blooser/9a849899233fc897bf1bcff46b7cda71 to your computer and use it in GitHub Desktop.
Save blooser/9a849899233fc897bf1bcff46b7cda71 to your computer and use it in GitHub Desktop.
VU Meter Arduino
int diods[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
const int length = 11;
#define FOR(x, n) for(int x=0; x<n; x++)
void setup() {
FOR(x, length){
pinMode(diods[x], OUTPUT);
digitalWrite(diods[x], LOW);
}
}
int analogP = 5;
void loop() {
static int last = 0;
int input = analogRead(analogP);
input = abs(input - 512);
int current = map(input, 50, 380, 0, 11);
last = current;
int position;
for(position = 0; position<last; position++)
digitalWrite(diods[position], HIGH);
for(;position<rozmiar; position++)
digitalWrite(diods[position], LOW);
delay(5);
}

Tower

vu

Visual Meter

vu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment