Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Old Code
- int analogPin = 0; // read from multiplexer using analog input 0
- int strobePin = 2; // strobe is attached to digital pin 2
- int resetPin = 3; // reset is attached to digital pin 3
- int ledPin = 5; // Needs to be a pwm pin
- int spectrumValue[7]; // to hold a2d values
- // LED Bar pins that go to the base on their respective transistors
- int ledBarOne = 11;
- int ledBarTwo = 12;
- void setup()
- {
- Serial.begin(9600);
- pinMode(analogPin, INPUT);
- pinMode(ledPin, OUTPUT
- );
- pinMode(strobePin, OUTPUT);
- pinMode(resetPin, OUTPUT);
- analogReference(DEFAULT);
- digitalWrite(resetPin, LOW);
- digitalWrite(strobePin, HIGH);
- pinMode(ledBarOne, OUTPUT);
- pinMode(ledBarTwo, OUTPUT);
- digitalWrite(ledBarOne,LOW);
- pinMode(ledBarTwo,LOW);
- Serial.println("MSGEQ7 test by J Skoba");
- }
- void loop() {
- digitalWrite(ledBarOne,LOW);
- digitalWrite(ledBarTwo,LOW);
- digitalWrite(resetPin, HIGH);
- digitalWrite(resetPin, LOW);
- for (int i = 0; i < 7; i++) {
- digitalWrite(strobePin, LOW);
- delayMicroseconds(300); // to allow the output to settle
- spectrumValue[i] = analogRead(analogPin);
- int adjustedValue = spectrumValue[i];
- if (i == 0) {
- digitalWrite(ledBarOne, HIGH);
- Serial.print("LED BAR ONE ON -- ");
- Serial.print(adjustedValue);
- digitalWrite(strobePin, HIGH);
- analogWrite(ledPin, adjustedValue >> 3);
- }
- if (i == 5) {
- digitalWrite(ledBarTwo, HIGH);
- Serial.print("LED BAR TWO ON -- ");
- Serial.print(adjustedValue);
- digitalWrite(strobePin, HIGH);
- analogWrite(ledPin, adjustedValue >> 3);
- }
- if (i != 5 && i != 0) {
- Serial.print('NO LED BAR ON');
- }
- Serial.println();
- digitalWrite(strobePin, HIGH);
- analogWrite(ledPin, adjustedValue >> 3);
- delayMicroseconds(10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement