#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <SoftwareSerial.h>
#define F_CPU 16500000L
#define SERIAL_TX PB3
#define SERIAL_RX PB0
SoftwareSerial mySerial(SERIAL_RX, SERIAL_TX);
int main(void) {
uint8_t ch;
mySerial.begin(9600);
_delay_ms(100); // Waits serial initialization
sei(); // Enables the global interrupt
DDRB |= (0x01 << PB1); // Set PB1 (6) as OUTPUT
mySerial.write("Type in character or string...\n");
while (1) {
if (mySerial.available()) {
PORTB ^= (1 << PB1); // Toggle on/off LED
ch = mySerial.read();
mySerial.write(ch);
}
_delay_ms(5);
PORTB = ~(1 << PB1); // Turn off LED
}
return (0);
}