|
@@ -52,20 +52,29 @@ void us_transmit() {
|
|
|
delayMicroseconds(5);
|
|
|
PORTD = (PORTD & 0b11100011) | 0b00001000;
|
|
|
delayMicroseconds(5);
|
|
|
- PORTD = (PORTD & 0b11100011) | 0b00010000;
|
|
|
- delayMicroseconds(5);
|
|
|
|
|
|
- //pull pin 2, 3 and 4 to GND
|
|
|
- PORTD &= 0b11100011;
|
|
|
+ //pull pin 2 and 3 to GND
|
|
|
+ PORTD &= 0b11110011;
|
|
|
+ //set pin 2 and 3 back to input
|
|
|
+ DDRD &= 0b11110011;
|
|
|
|
|
|
- //set pin 2, 3 and 4 back to input
|
|
|
- DDRD &= 0b11100011;
|
|
|
+ delayMicroseconds(5);
|
|
|
|
|
|
//enable pin interrupts
|
|
|
EIMSK = _BV(INT1) | _BV(INT0);
|
|
|
|
|
|
usData[0].state = rxPending;
|
|
|
usData[1].state = rxPending;
|
|
|
+
|
|
|
+ PORTD = (PORTD & 0b11100011) | 0b00010000;
|
|
|
+ delayMicroseconds(5);
|
|
|
+
|
|
|
+ //pull pin 4 to GND
|
|
|
+ PORTD &= 0b11101111;
|
|
|
+
|
|
|
+ //set pin 4 back to input
|
|
|
+ DDRD &= 0b11101111;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
long us_get_duration(byte sensor) {
|