Skip to content

Instantly share code, notes, and snippets.

@Crenshinibon
Created October 28, 2012 13:52
Show Gist options
  • Save Crenshinibon/3968652 to your computer and use it in GitHub Desktop.
Save Crenshinibon/3968652 to your computer and use it in GitHub Desktop.
Carrier signal sending simple RF
const byte CARRIER=B10101010,PRE=0x5E,ADDR=0x10;
const byte START = 0xD0;
const byte STOP = 0xDF;
static void sendKeyState(){
if(stateChanged){
sendPackage(START);
for(int i = 0; i < pressedKeyIndex; i++){
sendPackage(pressedKeys[i]->id);
}
sendPackage(STOP);
}
else {
if(millis() - lastKeepAlive > 5){
Serial.write(CARRIER);
lastKeepAlive = millis();
}
}
}
static void sendPackage(byte data){
Serial.write(PRE);
Serial.write(ADDR);
Serial.write(data);
Serial.write(ADDR + data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment