Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int analogPin = 0;
- int strobePin = 2;
- int resetPin = 4;
- int spectrumValue[7];
- int filterValue = 170;
- int ledPinR = 9;
- int ledPinG = 10;
- int ledPinB = 11;
- void setup()
- {
- Serial.begin(9600);
- pinMode(analogPin, INPUT);
- pinMode(strobePin, OUTPUT);
- pinMode(resetPin, OUTPUT);
- analogReference(DEFAULT);
- digitalWrite(resetPin, LOW);
- digitalWrite(strobePin, HIGH);
- }
- void loop()
- {
- digitalWrite(resetPin, HIGH);
- digitalWrite(resetPin, LOW);
- for (int i = 0; i < 7; i++)
- {
- digitalWrite(strobePin, LOW);
- delayMicroseconds(45);
- spectrumValue[i] = analogRead(analogPin);
- spectrumValue[i] = constrain(spectrumValue[i], filterValue, 1023);
- spectrumValue[i] = map(spectrumValue[i], filterValue, 1023, 0, 255);
- Serial.print(spectrumValue[i]);
- Serial.print(" ");
- digitalWrite(strobePin, HIGH);
- }
- Serial.println();
- analogWrite(ledPinR, spectrumValue[1]);
- analogWrite(ledPinG, spectrumValue[4]);
- analogWrite(ledPinB, spectrumValue[6]);
- }
Advertisement
Add Comment
Please, Sign In to add comment