Untitled
unknown
plain_text
2 years ago
816 B
12
Indexable
#include <avr/io.h>
#include <util/delay.h>
#include <LCD.h>
#define BUFFER_SIZE 100 // Define buffer size for input string
int main (void) {
LCD lcd;
lcd.init();
char buffer[BUFFER_SIZE];
int bufferIndex = 0;
// Initialize UART here
while (1) {
if(checkbit(UCSRA, bitn(RXC))) {
char receivedData = UDR;
if (receivedData == '\n') {
buffer[bufferIndex] = '\0';
// process the buffer here (compare with categories)
// reset bufferIndex after processing
bufferIndex = 0;
} else if (bufferIndex < BUFFER_SIZE - 1) { // buffer overflow prevention
buffer[bufferIndex++] = receivedData; // store in buffer and increment index
}
}
}
}
Editor is loading...
Leave a Comment