Added IR distance code

This commit is contained in:
2019-04-14 01:22:22 -07:00
parent 18c96a7ee5
commit 610bc546c9
3 changed files with 148 additions and 19 deletions

30
main.c
View File

@@ -3,8 +3,8 @@
#include <stdio.h>
#include <stdarg.h>
#include <util/setbaud.h>
#define LED PORTB5
#define WIRE PORTB0
#define LED PORTD2
#define WIRE PORTD3
void uart_init() {
@@ -39,23 +39,23 @@ int main(void) {
uart_init();
DDRB |= (1 << LED);
DDRB |= (1 << WIRE);
DDRC &= ~(1<<0); // Input
PORTC |= (1<<0); // Enable Internal Pull Up (Setting it to HIGH)
DDRD |= (1 << WIRE);
for(;;){
uart_putstr("hello\n");
_delay_ms(100);
PORTB |= (1 << LED);
PORTB |= (1 << WIRE);
_delay_ms(100);
PORTB &= (0 << LED);
PORTB &= (0 << WIRE);
_delay_ms(900);
PORTD |= (1 << WIRE);
_delay_ms(900);
PORTD &= (0 << WIRE);
uint8_t port_value = 0;
port_value = PINC & (1 << 0);
uart_putchar((char)port_value);
uart_putstr("\n");
}
}