All,
I am trying to basically replicate the functionality that I have working in my Arduino with the RCswitch library. I have hooked into a simple 433 remote control that controls 433 receivers around the house. I am able to use the library to send pulses (tri-state) from the Arduino by hooking into the output pin of the remote control.
The shortest high pulse is about 230 microseconds in length and the whole packet can contain up to 32 pulses. I tried doing the following in the imp, but the pulses don’t seem to be coming out fast enough. Am I not supposed to be able to do this?
Here is the code:
//let's try pulsing
local pulseLength = 0.000230;
local repeatTimes = 16;
local ledState = 0;
//hardware.pin2.configure(DIGITAL_OUT);
//hardware.pin1.configure(PWM_OUT, 0.001, 1);
hardware.pin1.configure(DIGITAL_OUT);
function sendTriState(chars) {
for(local i = 0; i < repeatTimes; i++ ) {
foreach(c in chars) {
switch(c) {
case '0':
sendT0();
break;
case '1':
sendT1();
break;
case 'F':
sendTF();
break;
}
}
sendSync();
}
}
function sendT0() {
transmit(1, 3);
transmit(1, 3);
}
function sendT1() {
transmit(3, 1);
transmit(3, 1);
}
function sendTF() {
transmit(1, 3);
transmit(3, 1);
}
function sendSync() {
transmit(1, 31);
transmit(1, 31);
}
function transmit(highCount, lowCount) {
//server.log("sending: " + highCount);
hardware.pin1.write(1);
imp.sleep(highCount * pulseLength);
hardware.pin1.write(0);
imp.sleep(lowCount * pulseLength);
}
function cycleTheLights() {
//ledState = ~ledState;
//hardware.pin1.write(ledState);
sendTriState(['1','F','1','F','F','F','F','1','0','0','0','0']);
imp.sleep(0.3);
//sendTriState(['1','F','1','F','F','F','F','1','0','0','0','0']);
//imp.sleep(0.3);
imp.wakeup(2, cycleTheLights);
}
imp.configure("Remote Switch",[],[]);
server.log("sending tri state");
cycleTheLights();