4 ms·
For others who are to lazy to link follow the linked article from the original article, there is a section of code in the function "loop" (modified for readabil
by abetusk 7y ago
For others who are to lazy to link follow the linked article from the original article, there is a section of code in the function "loop" (modified for readability):
void loop () {
// if clock is LOW wait until it turns to HIGH
//
while (digitalRead(clockpin)==HIGH) {}
tempmicros=micros();
// wait for the end of the HIGH pulse
//
while (digitalRead(clockpin)==LOW) {}
// if the HIGH pulse was longer than 500 micros
// we are at the start of a new bit sequence
//
if ((micros()-tempmicros)>500) {
decode(); //decode the bit sequence
}
}
so it looks like the 24 bit sequence is indicated by a 500 us pause between a falling edge and a rising edge of the data stream.
[1] https://sites.google.com/site/marthalprojects/home/arduino/arduino-reads-digital-caliper https://sites.google.com/site/marthalprojects/home/arduino/a...
- unwind 7y agoI love that the input is using inverted logic due to the voltage translation needed, but the code and comments don't mention this. To me it looks like an obvious bug and first glance, since the CAPITALIZED sigal states don't match between code and comments. Glad I read the article first. :)