#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
char in_byte;
init(); // Arduino initialisation (including serial ports)
// Intitialise serial port 0
Serial.begin(9600);
while(1)
{
if (Serial.available() > 0) // This checks when there is serial data
{ // loaded into the buffer from an external source
in_byte = Serial.read();
Serial.write("Test");
// Serial.println(in_byte, DEC);
// Write your code loop in here
if (in_byte == '1'){
Serial.println("Number 1 recieved");
}
{
if (in_byte == '2')
Serial.println("Number 2 recieved");
}
}
delay(1000);
return 0;
//Write your code loop in here
}
}
/*}
Now that the code is set for Serial Port reading and writing, implement the following into your code.
When the value ‘1’ is entered into the Serial Monitor, send the string “Number 1 received”
When the value ‘2’ is entered into the Serial Monitor, send the string “Number 2 received”
Code is to loop, displaying the message every 1 second. */