You plug on end into your computer and it looks at your Lync status to determine if you are available, busy, or away from your computer. They are a handy way to determine at a glance if somebody is available for an impromptu meeting.
And they only work on Windows' computers. Having a Mac, I've been out of luck.
Recently fed up with the performance of Lync as my softphone, I requested a desk phone and the one I got (Polycom CX600) logs into Lync from the phone. Furthermore, it has a little circling arrow icon on the phone that lights up with the appropriate status color.
In what is surely the least attractive way of doing this, I've mounted a color sensor over that double-arrow icon and use it to determine my current status. With that information, I drive a string of RGB LEDs to the appropriate color. My cube looks something like this and I've installed the LEDs so they shine on frosted glass above my desk.
Details:
- Color sensor is TCS230. You toggle two control (S2 and S3) pins to select the color to measure and it varies the frequency of a square wave depending on the intensity of that light. You can reduce the overall frequency of the device (pins S0 and S1) to a few different levels and I choose the lowest scale to help make the measurement easier. Measuring frequency is done by...
- ... Arduino's have a pulseIn function that can be used to measure the length of half a period of the output frequency. When a given color is very dark the output frequency is low and the pulse length is long. When the color being measured is bright, the frequency is high and the pulse length is short. Based on these measurements, I can classify the input color as red, green, or yellow and set the output PWM period of three transistor driving those colors on..
- ... two meters of RGB LEDs. These are 12V LEDs and they are all one color, different than those that I used for my Lorenz project. I used some higher-power transistors I have laying around MPT16N25E to drive them. Maximum current for these lights is 2A which is being split across three transistors. That current would only show up for maximum bright "white" light (full red, green, and blue power) so I don't really have much to worry about.
- I used a a 250V 2A polyfuse for protection on the 12V supply. The power supply plugs into the Ardiuno barrel jack and then I tap the "Vin" pin for the 12V I need for the LEDs. The on-board polyfuse protects the Arduino but not the transistors and LED string.
The system has been running for a week or two without much incident. The only tricky part was getting the sensor firmly attach to the light on the phone so the color measurements were consistent. I've been getting good feedback from my co-workers, especially those that realized it was more than decoration. Overall, I think we could call this a success.
Here's the schematic, picture of the board as completed, and source code:
Here's the schematic, picture of the board as completed, and source code:
// Used to measure the status light color off a Lync-enabled desk phone and drive RGB LEDs to the same color
// 2016 Trevor Hardy
const int pinTCS230_S2 = 3;
const int pinTCS230_S3 = 4;
const int pinTCS230_Out = 2;
const int pinRedLed = 9;
const int pinGreenLed = 10;
const int pinBlueLed = 11;
const unsigned int max_width = 65000; //determined experimentally.
unsigned int PW_divisor = 0;
unsigned int pulseWidth = 0;
int TCS230_red = 0;
int TCS230_green = 0;
int TCS230_blue = 0;
int red_out = 0;
int blue_out = 0;
int green_out = 0;
// the setup routine runs once when you press reset:
void setup() {
Serial.begin(250000);
// declare pin 9 to be an output:
pinMode(pinRedLed, OUTPUT);
pinMode(pinGreenLed, OUTPUT);
pinMode(pinBlueLed, OUTPUT);
pinMode(pinTCS230_S2, OUTPUT);
pinMode(pinTCS230_S3, OUTPUT);
pinMode(pinTCS230_Out, INPUT);
PW_divisor = max_width/256;
}
// the loop routine runs over and over again forever:
void loop() {
read_TCS230();
Serial.print("Red: ");
Serial.println(TCS230_red);
Serial.print("Green: ");
Serial.println(TCS230_green);
Serial.print("Blue: ");
Serial.println(TCS230_blue);
if ( TCS230_red > 200){
//Red
red_out = 127;
green_out = 0;
blue_out = 0;
Serial.println("Red\n");
}
else if (TCS230_green > 120 && TCS230_red < 120 ){
//Green
red_out = 0;
green_out = 127;
blue_out = 0;
Serial.println("Green\n");
}
else if (TCS230_red > 150 && TCS230_green > 150){
//Amber
red_out =200;
green_out = 63;
blue_out = 0;
Serial.println("Amber\n");
}
else {
red_out = 0;
green_out = 0;
blue_out = 0;
Serial.println("Off\n");
}
analogWrite(pinRedLed, red_out);
analogWrite(pinGreenLed, green_out);
analogWrite(pinBlueLed, blue_out);
//delay(1000);
}
void read_TCS230()
{
digitalWrite(pinTCS230_S2, LOW);
digitalWrite(pinTCS230_S3, LOW);
//pulseWidth = pulseIn(pinTCS230_Out, digitalRead(pinTCS230_Out) == HIGH ? LOW : HIGH);
pulseWidth = pulseIn(pinTCS230_Out, LOW);
if (pulseWidth == 0){
pulseWidth = max_width;
}
//Serial.print("Red pulsewidth: ");
//Serial.println(pulseWidth);
TCS230_red = 255 - (pulseWidth/PW_divisor - 1);
digitalWrite(pinTCS230_S2, HIGH);
digitalWrite(pinTCS230_S3, HIGH);
pulseWidth = pulseIn(pinTCS230_Out, LOW);
if (pulseWidth == 0){
pulseWidth = max_width;
}
//Serial.print("Green pulsewidth: ");
//Serial.println(pulseWidth);
TCS230_green = 255 - (pulseWidth/PW_divisor - 1);
digitalWrite(pinTCS230_S2, LOW);
digitalWrite(pinTCS230_S3, HIGH);
pulseWidth = pulseIn(pinTCS230_Out, LOW);
if (pulseWidth == 0){
pulseWidth = max_width;
}
Serial.print("Blue pulsewidth: ");
Serial.println(pulseWidth);
TCS230_blue = 255 - (pulseWidth/PW_divisor - 1);
}
No comments:
Post a Comment