@krisztian
Hi krisztian,
the singleLED board - as its name suggests - features only one LED output. If you want to have a setup with multiple LED strips you need to design a board with multiple outputs. I have already designed a board with 4 outputs, but I haven't built it.
In terms of software you need to register multiple sensors in your program like this:
#define numCh 4 //the number of outputs
const byte ledPins[] = {9,6,5,3};
byte ledLevel[numCh];
boolean ledDimWay[numCh];
//in the setup function request the dim levels from the gateway
for(byte i=0; i<numCh; i++) request(i, V_DIMMER);
//in the presentation function register multiple lights
for(byte i=0; i<numCh; i++) present(i, S_DIMMER);
//if you receive a signal, you need to check for the sensor id
setLED(message.sensor, requestedLevel);
//to set the LED level (function: setLED) you need to use the sensor id to determine brightness and pin
//Fade LED to set level
int delta = (level - ledLevel[child]) < 0 ? -1 : 1;
//Write to LED
analogWrite(ledPins[child], map(ledLevel[child],0,100,0,255));
I will probably publish the whole code once I have built and tested the 4LED controller (i call it "MySensors rainbowLED")
Hope I could help you
ThetaDev
Just to let you know that I solved the issue.
I found a library where you can control the speed and make sure it get to it's position.
You can find it here: https://github.com/netlabtoolkit/VarSpeedServo
I incorporated it in the Mysensor sketch and it works eventhoug it looks like it only goes like 90 degrees but it's enough for me :
#include <MySensor.h>
#include <SPI.h>
#include <VarSpeedServo.h>
// #include <Servo.h>
#define SERVO_DIGITAL_OUT_PIN 3
#define SERVO_MIN 0 // Fine tune your servos min. 0-180
#define SERVO_MAX 180 // Fine tune your servos max. 0-180
#define DETACH_DELAY 900 // Tune this to let your movement finish before detaching the servo
#define CHILD_ID 10 // Id of the sensor child
MySensor gw;
MyMessage msg(CHILD_ID, V_DIMMER);
VarSpeedServo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
// Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created Sensor gw(9,10);
unsigned long timeOfLastChange = 0;
bool attachedServo = false;
void setup()
{
// Attach method for incoming messages
gw.begin(incomingMessage);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Servo", "1.0");
// Register all sensors to gw (they will be created as child devices)
gw.present(CHILD_ID, S_COVER);
// Request last servo state at startup
gw.request(CHILD_ID, V_DIMMER);
}
void loop()
{
gw.process();
if (attachedServo && millis() - timeOfLastChange > DETACH_DELAY) {
myservo.detach();
attachedServo = false;
}
}
void incomingMessage(const MyMessage &message) {
myservo.attach(SERVO_DIGITAL_OUT_PIN);
attachedServo = true;
if (message.type==V_DIMMER) { // This could be M_ACK_VARIABLE or M_SET_VARIABLE
int val = message.getInt();
myservo.write(SERVO_MAX + (SERVO_MIN-SERVO_MAX)/100 * val,255,true); // sets the servo position 0-180
// Write some debug info
Serial.print("Servo changed. new state: ");
Serial.println(val);
} else if (message.type==V_UP) {
Serial.println("Servo UP command");
myservo.write(SERVO_MIN,255,true);
gw.send(msg.set(100));
} else if (message.type==V_DOWN) {
Serial.println("Servo DOWN command");
myservo.write(SERVO_MAX,255,true);
gw.send(msg.set(0));
} else if (message.type==V_STOP) {
Serial.println("Servo STOP command");
myservo.detach();
attachedServo = false;
}
timeOfLastChange = millis();
}
@antonholmstedt a pro mini fits if you cut the corners, check out https://forum.mysensors.org/topic/6612/door-sensor-remix-of-some-mys-community-efforts
@WiktorDIY The ch340 are notorious for being broken. The best I ever achieved was 19200 and flakey..
I purchased a real Nano not a ch knock off eg uses a different uart no problems