Could you someone to remake the code to be anrduio as a transmitter for weather station. Nonetheless, the code is decoded so well.
This is not working, help someone with it?
I'd like to show on the weather station SENCOR SWS 60 (transmitter SWS THS).
/*
A B A B A B
_a_ c.............. _a_ c....... _a_ c... ___
| | | | | | | |
___| |_________________| |__________| |______| |
Synchronising Logic 1 Logic 0
m n o p q r s
*/
int TxPin = 13;
// Constants in micro seconds
const unsigned long sync = 8320; //8600
const unsigned long logic1 = 4500; //4300
const unsigned long logic0 = 2530; //1800
const unsigned long blip_length = 300; //430 // Anything below this value is a glitch and will be ignored.
byte data_bytes[36] = {1,0,0,0,1,0,1,1,1,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,1,1,1,1,0,0,1,0,1,0,1,1};
boolean last_transmit = false; //if last transmit (8); cut last 4bits - not needed for this temperature
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
pinMode(TxPin,OUTPUT);
}
void loop() {
for (int x = 0; x < 8; x++) { repeatings of sending temperature //<8
if (x == 7) {
last_transmit = true;
Serial.println();
}
synch();
for (int i = 0; i < 36; i++) { //reading and sending bits of temerature; 36 = length of bit stream
//Serial.print(data_bytes[i]);
//Serial.println(i);
switch (data_bytes[i]) {
case 0:
logic_0();
break;
case 1:
logic_1();
break;
} //end switch
/*// this temperature doesn't need this
if ((last_transmit) && (i == 23)) { //last transmit doesn't have last 4 bits; so skip them
i = 28;
} //end if
*/
} //end for i
//Serial.println();
} //end for x
if (last_transmit) { //just stop sending
delay(4000);
Serial.println("pauza");
}
} //end loop
//n - o
void synch() {
blip();
delayMicroseconds(sync);
}
//p - q
void logic_1() {
blip();
delayMicroseconds(logic1);
Serial.print(1);
}
//t - s
void logic_0() {
blip();
delayMicroseconds(logic0);
Serial.print(0);
}
//a
void blip() {
digitalWrite(TxPin, HIGH);
delayMicroseconds(blip_length);
digitalWrite(TxPin,LOW);
}