Connecting Arduino to TW523
40Watt light bulb to lamp module set to House code P, device 1
TW523 and lamp module connected to the same plug.
I have this simple code:
#include <x10.h>
#include <x10constants.h>
#define zcPin 2 // the zero crossing detect pin
#define dataPin 3 // the X10 data out pin
x10 myHouse = x10(zcPin, dataPin);
void setup() {
Serial.begin(9600);
myHouse.write(HOUSE_P, UNIT_1, 1);
myHouse.write(HOUSE_P, OFF, 1);
}
void loop() {
for(int i=1; i<21; i++){
myHouse.write(HOUSE_P, UNIT_1, 1);
myHouse.write(HOUSE_P, ON, 1);
delay(3000);
Serial.println(i);
delay(1000);
myHouse.write(HOUSE_P, DIM, i);
delay(1000);
}
}
What I am expecting is the light to turn ON and DIM=1, ON again and DIM=2, ON again and DIM=3, etc...
What is actually happening is the light turns ON and it DIMs at each cycle of i between 2 to 6. when i=6 the light is very DIM almost off and no difference between i=6 to 20
The light never go back to ON between cycles.
I've tried setting the ON command with 3 repeats.
I've tried different house codes.
How does the DIM and BRIGHT commands work? is the repeat time = 1 to 100 to generate 1% to 100%?
And why doesn't my code work as it should?