Hey everyone,
Having issues with a device we have set up.
Essentially we have connected the board to to a breadboard with an LED in it. We have used the PWM pins (USV) for the RGB and are using a Slack command to call the different colours.
The commands work correctly as we are seeing the calls appear in the IMP logs, however the only colour that actually appears is the Blue. Neither the Green or the Red seem to be getting power sent to them.
The board appears to be set up correctly but open to any help anyone can provide.
Device Code
//***********IMP 2.0 LED CODE******************
// Pin Assignments
// Pin U = PWM for Red
// Pin S = PWM for Green
// Pin V = PWM for Blue
// Configure Hardware
hardware.pinU.configure(PWM_OUT, 0.001752, 1.0); // Red
hardware.pinS.configure(PWM_OUT, 0.001752, 1.0); // Green
hardware.pinV.configure(PWM_OUT, 0.001752, 1.0); // Blue
local currentColor = null;
class RgbLed
{
// IO Pin assignments
pinR = null;
pinG = null;
pinB = null;
constructor(r, g, b)
{
// Save pin assignments
pinR = r;
pinG = g;
pinB = b;
// Initialise as inactive
setLevels(0, 0, 0);
}
// Set red, green and blue intensity levels
function setLevels(r, g, b)
{
// output pin is configured for PWM, we can set the duty cycle with pin.write()
// write a floating point number between 0.0 and 1.0, where 1.0 = 100% duty cycle
//server.log("RgbLed.setLevels");
this.pinR.write(r/1.0);
this.pinG.write(g/1.0);
this.pinB.write(b/1.0);
}
}
led <- RgbLed(hardware.pinU, hardware.pinS, hardware.pinV);
//}
//************Color Request******************
//{
agent.on("ColorRequest", function(x)
{
local r = x[0].tointeger();
local g = x[1].tointeger();
local b = x[2].tointeger();
led.setLevels(r,g,b);
currentColor = x;
});
//}
//}
//}
//************Status Request******************
agent.on("statusRequest", function(x)
{
agent.send("Status", currentColor);
});
//************Restart Request******************
agent.on("restartRequest", function(x)
{
server.restart();
});