Before starting this project, you must have first integrated the Arduino Lilypad Library as without it you wont be abe to do this project. So, if you haven't downloaded it yet then you should read the previous post Arduino Lilypad / Nano Library for Proteus first. Lets get started with this project.
Arduino Lilypad Simulation in Proteus
- Now I assue that you have already downloaded the Arduino Lilypad Library for Proteus and are ready to use it within Proteus.
- So open Proteus ISIS and get these components from the Proteus components library as shown in below figure:
- After getting these components, draw a circuit in Proteus as shown in the below figure:

- You can clearly see in the above figure, the Arduino Lilypad Simulation in Proteus. After that you need to write a code for Arduino Lilypad so that you could get the hex file for it.
- In this project, I have used three LED lights and make them ON and OFF using the switch button. If the button is not pressed then the LEDs will remain ON and when you hit the button , the LEDs will go OFF.
- Copy the below code and paste it into the Arduino software and compile.
int analogPin = A0; int ledCount = 3; int ledPins[] = { 2, 3, 4}; void setup() { // loop over the pin array and set them all to output: for (int thisLed = 0; thisLed < ledCount; thisLed++) { pinMode(ledPins[thisLed], OUTPUT); } } void loop() { // read the potentiometer: int sensorReading = analogRead(analogPin); // map the result to a range from 0 to the number of LEDs: int ledLevel = map(sensorReading, 0, 1023, 0, ledCount); // loop over the LED array: for (int thisLed = 0; thisLed < ledCount; thisLed++) { // if the array element's index is less than ledLevel, // turn the pin for this element on: if (thisLed < ledLevel) { digitalWrite(ledPins[thisLed], HIGH); } // turn off all pins higher than the ledLevel: else { digitalWrite(ledPins[thisLed], LOW); } } }
- After compiling this code, get the hex file of code. The hex file and this simulation file is also given at the end of this post so you can download it from there.
- Now upload this hex file into this Arduino Lilypad and hit the RUN button
- If you dont know how to get the hex file from Arduino software, then read Arduino Library For Proteus.
- If everything's goes fine then as youhit the run button, the LEDs will get ON as shown in the below figure:

- Now, when you press the button, these LEDs will go OFF as shown in the below figure:

- That's all, you have successfully implemented the Arduino Lilypad simulation in Proteus. :)
- In order to download this simulation and the hex file, click on the below buttons.