Skip to content

Instantly share code, notes, and snippets.

@OsoianMarcel
OsoianMarcel / Ultrasonic_SR04_Atmega8_8Mhz_Timer0_Basic_Example.c
Last active Jan 22, 2021
Basic Example - How to use Ultrasonic SR04 distance sensor with Atmega8 and Timer0 (8Mhz)
View Ultrasonic_SR04_Atmega8_8Mhz_Timer0_Basic_Example.c
// Notice: 8 Mhz frequency is expected
#define SONIC_DDR DDRC
#define SONIC_PORT PORTC
#define SONIC_PIN PINC
#define SONIC_TRG_PIN PINC0
#define SONIC_ECHO_PIN PINC1
#include <avr/io.h>
#include <util/delay.h>