-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathusound.h
More file actions
32 lines (22 loc) · 851 Bytes
/
usound.h
File metadata and controls
32 lines (22 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*********************************************************************************/
/* Ultrasonic range finder HC-SR04 lib for AVR */
/* Autor: Kornuta Taras */
/* Date: 21.04.2016 */
/* URL: http://digiua.com */
/*********************************************************************************/
#ifndef USOUND_H
#define USOUND_H
#include <avr/io.h>
#include <avr/interrupt.h>
#include <inttypes.h>
#include <util/delay.h>
// Ports initialization
#define US_DDR DDRD
#define US_PORT PORTD
#define US_PIN PIND
#define US_TRIGER PIND2
#define US_ECHO PIND4
void usound_init(void); //Paste in Main function
uint32_t readDistance(void); //Return the distance in centimeters
//Recommended use this function with 20Hz frequency
#endif //USOUND_H