avrdude: error: usbtiny_transmit: usb_control_msg: sending control message failed, win error: A device attached to the system is not functioning.
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude: error: usbtiny_transmit: usb_control_msg: sending control message failed, win error: A device attached to the system is not functioning.
Here is my code:
Code: Select all
int analogPin = 1; // MSGEQ7 OUT
int strobePin = 12; // MSGEQ7 STROBE
int resetPin = 11; // MSGEQ7 RESET
int spectrumValue[7];
// MSGEQ7 OUT pin produces values around 50-80
// when there is no input, so use this value to
// filter out a lot of the chaff.
int filterValue = 80;
// LED pins. I used 2 common cathode RGB LEDs.
// They're connected to the PWM pins on the Arduino
int ledPinR1 = 3;
int ledPinG1 = 4;
int ledPinB1 = 5;
void setup()
{
// Read from MSGEQ7 OUT
pinMode(analogPin, INPUT);
// Write to MSGEQ7 STROBE and RESET
pinMode(strobePin, OUTPUT);
pinMode(resetPin, OUTPUT);
// Set analogPin's reference voltage
analogReference(DEFAULT); // 5V
// Set startup values for pins
digitalWrite(resetPin, LOW);
digitalWrite(strobePin, HIGH);
}
void loop()
{
// Set reset pin low to enable strobe
digitalWrite(resetPin, HIGH);
digitalWrite(resetPin, LOW);
// Get all 7 spectrum values from the MSGEQ7
for (int i = 0; i < 7; i++)
{
digitalWrite(strobePin, LOW);
delayMicroseconds(30); // Allow output to settle
spectrumValue[i] = analogRead(analogPin);
// Constrain any value above 1023 or below filterValue
spectrumValue[i] = constrain(spectrumValue[i], filterValue, 1023);
// Remap the value to a number between 0 and 255
spectrumValue[i] = map(spectrumValue[i], filterValue, 1023, 0, 255);
// Remove serial stuff after debugging
// Serial.print(spectrumValue[i]);
// Serial.print(" ");
digitalWrite(strobePin, HIGH);
}
// Serial.println();
// Write the PWM values to the LEDs
analogWrite(ledPinR1, spectrumValue[0]); // 63Hz
analogWrite(ledPinR1, spectrumValue[1]); // 160Hz
analogWrite(ledPinB1, spectrumValue[3]); // 1000Hz
analogWrite(ledPinB1, spectrumValue[4]); // 2500Hz
analogWrite(ledPinG1, spectrumValue[5]); // 6250Hz
analogWrite(ledPinG1, spectrumValue[6]); // 16KHz
}
Please help if you can! Thank you!