Macegr was kind enough to send me a plugin for winamp that would send data via the serial port with the SSC format. this is the code i'm trying to build so i can get an led to pulse to music.
the first part is a small log of what winamp is sending out. When i use the serial monitor and input "ÿò........." or "ÿò" it takes the first one off which is 255 of and reads and prints the second value. in this case it's 242. and the led turns on. but when winamp is sending out the data nothing happens..
i do know that i have the plugin configured to the right port because i've had mixed results in the past with the led blinking but not working correctly.. and when i would stop the plugin the light would turn off instantly.
any information you could share would be helpful.
thanks for your time,
Dave.
[10/02/2010 15:20:38]
93 IRP_MJ_WRITE - Request transfers data from a client to a COM port
STATUS_SUCCESS
255 225 000 000 000 000 000 000 000 000 000 ÿá.........
----------------------------------------------------------------------------------
[10/02/2010 15:20:38]
95 IRP_MJ_WRITE - Request transfers data from a client to a COM port
STATUS_SUCCESS
255 235 000 000 000 000 000 000 000 000 000 ÿë.........
----------------------------------------------------------------------------------
[10/02/2010 15:20:38]
97 IRP_MJ_WRITE - Request transfers data from a client to a COM port
STATUS_SUCCESS
255 242 000 000 000 000 000 000 000 000 000 ÿò.........
----------------------------------------------------------------------------------
[10/02/2010 15:20:38]
99 IRP_MJ_WRITE - Request transfers data from a client to a COM port
STATUS_SUCCESS
255 242 000 000 000 000 000 000 000 000 000 ÿò.........
----------------------------------------------------------------------------------
const int ledPin = 9;
const int ledPin2 = 10;
const int ledPin3 = 11;
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
}
void loop() {
int value = 0;
if (Serial.available() >= 2) {
byte i = Serial.read();
if (int(i) == 255) {
byte in = Serial.read();
value = int(in);
}
}
if (value > 0) {
Serial.print(value);
if (value > 0 && value < 150) {
analogWrite(ledPin, 10);
Serial.print(value);
}
if (value >= 150 && value < 220) {
analogWrite(ledPin, 100);
Serial.print(value);
}
if ( value >= 220 && value <=254) {
analogWrite(ledPin, 255);
Serial.print(value);
}
}
}
// -------- end solution 1 ---------------
//----------- solution 2 ----------------
/*
if (value > 0 && value < 230) {
analogWrite(ledPin, 100);
analogWrite(ledPin2, 0);
analogWrite(ledPin3, 0);
}
if (value >= 230 && value < 240) {
analogWrite(ledPin, 100);
analogWrite(ledPin2, 100);
analogWrite(ledPin3, 0);
}
if ( value > 240 && value <=254) {
analogWrite(ledPin, 100);
analogWrite(ledPin2, 100);
analogWrite(ledPin3, 100);
}
*/
// ------------- end