Created
October 28, 2012 13:52
-
-
Save Crenshinibon/3968652 to your computer and use it in GitHub Desktop.
Carrier signal sending simple RF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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