Friday, 22 May 2015

Arduino Serial communication in proteus using Virtual Terminal

we can simulate the arduino serial communication using virtual terminal in the proteus

virtual terminal in proteus is located at instruments logo which highlighted as Instruments and can be located
virtual termina;
in the instruments we can choose the virtual instrument

we can select the serial transmission characteristics such as baud rate, parity... etc

virtual terminal

code which is dumped into Arduino is

const int pin = 13;
void setup()
{
pinMode(pin,OUTPUT);
Serial.begin(9600);
Serial.println("enter y to ON and n to OFF");
}

void loop()
{
while(!Serial.available())
{
//wait until user enters the data
}

if(Serial.available())
{
char input = Serial.read();
switch(input)
{
case 'y':
Serial.println("you entered y led ON");
digitalWrite(pin,HIGH);
break;
case 'n':
Serial.println("you entered n led is OFF");
digitalWrite(pin,LOW);
break;
default:
Serial.println("you entered wrong character");
}//end of switch
}//end of If

}//end of loop

No comments:

Post a Comment