1int latchPin = 11;
2int clockPin = 9;
3int dataPin = 12;
4byte LEDs = 128 ;
5int rms;
6
7void lightUp() {
8 digitalWrite(latchPin, LOW);
9 shiftOut(dataPin, clockPin, LSBFIRST, LEDs);
10 digitalWrite(latchPin, HIGH);
11}
12
13void setup() {
14
15 Serial.begin(115200);
16 pinMode(latchPin, OUTPUT);
17 pinMode(dataPin, OUTPUT);
18 pinMode(clockPin, OUTPUT);
19}
20
21
22void loop() {
23
24rms=(Serial.readStringUntil('/r')).toInt();
25
26if(rms<50){
27 LEDs = 0;
28}
29else if(rms >50 && rms<100){
30 LEDs = 128;
31}
32else if(rms >100 && rms<150){
33 LEDs = 192;
34}
35else if(rms >150 && rms<200){
36 LEDs = 224;
37}
38else if(rms >200 && rms<250){
39 LEDs = 240;
40}
41else if(rms >250 && rms<300){
42 LEDs = 248;
43}
44else if(rms >300 && rms<350){
45 LEDs = 252;
46}
47else if(rms >350 && rms<400){
48 LEDs = 254;
49}
50else if(rms >400){
51 LEDs = 255;
52}
53
54else{
55
56}
57
58lightUp();
59}
taz108am
4 months ago
Any chance of the breadboard image? Can't see the details when the thing is in use in the dark.