monitor example sensor value
This commit is contained in:
parent
4e85110447
commit
e09dfd8f3e
|
@ -27,7 +27,6 @@ void uart_printc(char c) {
|
|||
void uart_prints(char* s) {
|
||||
while(*s)
|
||||
uart_printc(*s++);
|
||||
uart_printc('\n');
|
||||
}
|
||||
char uart_getc() {
|
||||
while (UCSR0A & (1 << RXC0));
|
||||
|
|
14
print/main.c
14
print/main.c
|
@ -4,6 +4,8 @@
|
|||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "../include/uart.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define BAUD 9600
|
||||
#define MYUBRR F_CPU/16/BAUD-1
|
||||
|
@ -13,9 +15,19 @@ int main (void)
|
|||
{
|
||||
uart_init();
|
||||
sei();
|
||||
|
||||
char buf[10];
|
||||
int sensor;
|
||||
|
||||
while (1)
|
||||
{
|
||||
uart_prints("foofofofo");
|
||||
// lets say we read some value from a sensor
|
||||
sensor = 65;
|
||||
// we want to print this, so we store the ascii repr in our buffer
|
||||
itoa(sensor, buf, 10); // base 10
|
||||
uart_prints("sensor status: ");
|
||||
uart_prints(buf);
|
||||
uart_prints("\n");
|
||||
_delay_ms(1000);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue