Showing posts with label arduino proteus. Show all posts
Showing posts with label arduino proteus. Show all posts

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

Thursday, 21 May 2015

Arduino Relay driver using optocoupler in Proteus

In relay On condition
arduino_relay_ON

In relay Off condition
arduino_relay_off

Arduino Code is


const int pin =13;

void setup(){
pinMode(pin,OUTPUT);
Serial.begin(9600);
Serial.println("Please enter a char");
}

void loop(){
Serial.println("Please enter y to ON and n to OFF led");
while(!Serial.available())
{
//wait until user enters the data
}

char input;
if(Serial.available())
{
Serial.println(input = Serial.read());
if(input == 'y'){
Serial.println("you entered y led is ON");
digitalWrite(pin,HIGH);
}
else if(input == 'n'){
Serial.println("you entered n led is OFF");
digitalWrite(pin,LOW);
}
else{
Serial.println("you entered a wrong character");
}
}
}