In this project we are going to show you a simple Arduino program which controls an LED via Serial Communication using Proteus . High or Low command is given to the Arduino via PC terminal and the on board LED of Arduino is made ON/OFF through it. and simulation in proteus and make diagram in proteus. We create the arduino simulation in proteus using this arduino library. Arduino library is used to insert arduino in proteus. Arduino is a microcontroller board and is not available in proteus but using this arduino library you will be able to test your arduino code in proteus before designing the hardware.
Arduino Library for Proteus
- Download Arduino library for Proteus from the following link :
- Copy/Paste the library files into the following directory.
- Start Proteus, go to components and search for Arduino. Three Arduino boards will come up in the search i.e UNO, Mega1280 and Mega2560. Select the appropriate one. In our example we have selected UNO.
- Open Arduino IDE, compile the code and then try to upload it. Of course the IDE will generate an error because no physical Arduino is connected to the PC.. Don’t worry about it.
- Open start menu of your WINDOWS and type %temp%. This will show the hidden temporary folder of the windows. Open it.
- The project file which you compiled earlier on the Arduino IDE will be present there with an extension of .cpp.hex e.g XYZ.cpp.hex.
- Download that hex file into the Arduino model on your Proteus screen.
- 1) Hit the play button and we are good to go. Enjoy..!
int uno_led = 13; //LED on pin 13 of UNO//
Serial.begin(9600); //open serial port at BR=9600//
while(!Serial); //wait for serial port to be ready//
pinMode(uno_led, OUTPUT); //set pin 13 as output//
char x= (char)(Serial.read()); //Serial.read() returns “int”, therfore typecast it to “char”//
if(x == ‘H’)
digitalWrite(uno_led, HIGH); //turn on the LED when ‘H’ is sent through TERMINAL//
if(x == ‘L’)
digitalWrite(uno_led, LOW); //turn off the LED when ‘L’ is sent through TERMINAL//
if(x == ‘/0’) //if nothing is being transmitted via terminal, do nothing//
__asm__(“nop\n\t”); // double underscores before and after ‘asm’//
Serial.write(” “); // write nothing on terminal, ‘write’ function takes strings (” “) not char (”) //
delay(10); //delay function called//