Last active
July 30, 2018 19:50
-
-
Save blooser/9a849899233fc897bf1bcff46b7cda71 to your computer and use it in GitHub Desktop.
VU Meter Arduino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment