0% found this document useful (0 votes)
55 views21 pages

Lab 01 Led 2025

This document provides an introduction to Arduino and LED, detailing objectives, facilities, prerequisites, and an overview of the Proteus Design Suite for circuit simulation. It explains how to create a project in Proteus, collect necessary components, connect circuits, and run simulations, as well as the basics of Arduino, its types, and programming. Additionally, it covers the integration of Arduino with Proteus for simulating Arduino code and includes essential programming concepts and functions.

Uploaded by

23110340
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views21 pages

Lab 01 Led 2025

This document provides an introduction to Arduino and LED, detailing objectives, facilities, prerequisites, and an overview of the Proteus Design Suite for circuit simulation. It explains how to create a project in Proteus, collect necessary components, connect circuits, and run simulations, as well as the basics of Arduino, its types, and programming. Additionally, it covers the integration of Arduino with Proteus for simulating Arduino code and includes essential programming concepts and functions.

Uploaded by

23110340
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Lab 1 : INTRODUCTION ARDUINO AND LED

1. Objectives: After this lab, the learner will be able to


- Using proteus to simulate an simple IoT project
- Using Arduino IDE to program Arduino board
2. Facilities
- Arduino Software: Download from here
- Proteus Simulator
3. Prerequest
- Basis electronic
- C programming language
4. Introduction to Proteus
4.1. What is proteus
Proteus Design Suite is one of the best circuit simulation programs in its
field. It also has Proteus Design Suite, the PCB design, and IoT builder
software.

4.2. How can we use the program?

IoT Labs Pages 1


1. Creating a File:
After installing Proteus and activating your license, you will be met with a page
similar to that shown below:

“Getting Started” & “Help”: Some useful guides can be found here, but they tend to
be wordy and filled with jargon. It is advised to avoid them.
“Start” \ “Recent Projects”: Here you will find the projects that you opened last.
This section will be empty if you just installed Proteus.
“News”: This section will contain news about your current license, recent versions of
the software, and links to basic video tutorials that you might find helpful.
To create a new project, follow the steps below:
- Step 1: Click on “New Project” under the “Start” header in the home page:

The “New Project Wizard” window will now open


- Step 2: Choose a name and file-path for your project:

IoT Labs Pages 2


Then click “Next”.
- Step 3: Select the Schematic Design:

Unless certain dimensions are required (for printing or otherwise), “DEFAULT” will suffice.
Click “Next”.
- Step 3: Select the PCB Layout:

IoT Labs Pages 3


PCB design will not be included in this guide. Select “Do not create a PCB layout” and click
“Next
- Step 4: Select Firmware:

Editing source code is beyond the scope of this guide, select “No Firmware Project” and click
“Next”.
- Summary page:

You should now see a summary of all your previous selections. If any mistakes were made,
you can click “Back” and correct them.
- Click “Finish” to open the Schematic Capture module and begin working on your project.
2. Interface:

IoT Labs Pages 4


The Schematic Capture interface is split into four main parts, the Menu and Module bars on
top, the Sidebar on the left-hand side, the Root sheet in the center, and the Simulation Control
bar at the bottom.
Our circuits will be shown on the Root sheet, whereas most of our work will be done using
the Sidebar.
Module Bar:

Note: letter “M” before a number will indicate a button on the Module bar. Thus, M12 refers
to the “Copy” button on the Module bar.
Sidebar:

IoT Labs Pages 5


Note: letter “S” before a number will indicate a button on the Sidebar. Thus, S12 refers to the
“Device Picker” button on the Sidebar.
3. Collecting Parts:
In this part, we will prepare all the parts needed for our experiment. Experiment two will be
used to demonstrate the steps
Identify the needed parts:
0
Usually, all needed chips for a certain experiment are listed in its document.
.
The chips needed for experiment two are in the excerpt below:

7410 TRIPLE 3-INPUT NAND GATE, QTY = 2 Chips
7427 TRIPLE 3-INPUT NOR GATE, QTY = 2 Chips
7404 HEX INVERTER, QTY = 1 needed in order to make the variables and their
complements available.
7400 QUADRUPLE 2-INPUT NAND GATE, QTY = 1 Chip
7402 QUADRABLE 2-INPUT NOR GATE, QTY = 1 Chip
74283 4-BIT BIANRY ADDER

- Step 1: Open the Part Picker (S12 or M14):

- Step 2: After the “Pick Devices” window has appeared, begin writing keywords for the
part you are looking for:

IoT Labs Pages 6


- Step 3: Click “OK” to add the part to your list of components.
- Repeat step 2 for all other components while making sure that all components have
“Simulator Model(s)”. If “No Simulator Model” is not written, then it is assumed that
there is a simulator model for the selected component.
- Step 4: Now we add other required components such as: Switches, LEDs, Clock, etc.
Inputs: The two most common input components are “LOGICTOGGLE” and “SW-
SPDT” (Single Pole Double Throw) and can be added from “Device Picker”. There are
no practical differences between them.
5. Connecting a Circuit:
Once we have all the needed parts listed (in S14) in the Component Mode (S2), we are
ready to begin constructing a circuit. In this part, a half-adder will be constructed using
NOT gates and NOR gates (from experiment two)
6. Running the Simulator:
Perhaps the easiest part of this guide is running a simulation. Once all components are
connected, simply click the “Play” button at the bottom-left corner of the page.

7. Introduction to arduino
7.1. What is Arduino
- Arduino is nothing but a simple microcontroller board which is normally used in
engineering projects where there’s a need to automate something.
- You can interface sensors with this board, can drive motors with this board, can
plug switches in it etc.
- In old ages ( not old enough 😛 ), people used simple switches for turning ON a
bulb so like you click the switch and the bulb is ON, it was quite a simple circuit,
after that relays are invented and then engineers used 555 timer circuits in order
to turn ON lights on some specific time. But the 555 timer circuits are quite big
IoT Labs Pages 7
in size, so finally engineers discovered Microcontrollers in which there are
simple OUTPUT and INPUT pins, so now if you want to turn on light at some
certain time then you just simply plug the blub on output pin of microcontroller
and then do some programming and add a timer to automatically turn on the
bulb.
- So, the benefit of microcontroller is the circuit is quite simple and small in
size.Moreover, its flexible, suppose you want to change the time of turning ON
bulb then what you need to do is simply change the coding and it will be
changed, but in 555 timer circuits you need to change the components in order
to do so.
- Now, we know the use of microcontroller and also their benefit but thing is what
is Arduino ??? In microcontrollers like PIC or Atmel, there’s a small drawback.
- Suppose you want to work on PIC then you have to first design its basic circuit
also need to design a power circuit to supply power to it and after that in order
to upload the code in it, you have to buy a programmer/ burner as well. So, first
of all you need to write the code for PIC Microcontroller and after that you need
to upload code in it using a programmer and then plce PIC microcontroller back
into the circuit and test, which is quite lengthy plus also got hectic when you are
working on some project because you have to test code again and again.
- By the way, now advance programmers like PICkit2 and PICkit3 can be plugged
on board but still you have to design the basic circuit so coming to bottom line,
in order to do project with PIC or Atmel microcontroller you have to do soldering
etc.
- But that’s not the case with Arduino Board, Arduino has built in programmer and
the basic circuit in it. So what you need to do is simply plug in Arduino with your
computer via usb cable, get its software and start uploading code and also start
testing.
- So, you don’t need to plug unplug or do anything, simply upload the code and
test. Moreover, it also has some very efficient tools using which you can test
your output as well quite easily. Arduino board also has the pins on which you
can simply plug your devices and can turn them ON or OFF. So, hats off to
Arduino team for providing us a simple board which has everything on it.
7.2. Types of Arduino Boards

IoT Labs Pages 8


- There’s a long range of Arduino boards available online, the basic Arduino board
is named as Arduino UNO which is most widely used in projects.
- Arduino UNO has total 13 digital pins and 6 analog pins which are used for
connecting sensors with them.
- Suppose you have a project in which you want to interface 30 sensors, then
what you need to do ?? Now you need to buy another Arduino board named as
Arduino Mega 2560. This board has around 70 pins on it which can be used as
output or input and hence you can plug your sensors quite easily.

7.3. The Arduino Microcontroller: Atmel ARV Atmega 328

IoT Labs Pages 9


7.4. What is the Arduino

7.5. How to use Arduino


- Now I think you have got the basic idea of what is Arduino ? and why is it so
popular ? So now lets have a look at how to use Arduino.
- When you order for your Arduino board, you will get a package similar to the
image below:

-
- Along with this box, you will also have the USB cable, now take your Arduino
board out of this box and plug the cable in it, connect the Arduino with your
computer and you are ready to start working on it.
- In order to connect Arduino with your computer you have to install the Arduino
drivers in Windows.
- That’s all for today, hope I have conveyed some knowledge and you now know
the basics of Arduino i.e. what is Arduino ? and why to use Arduino.

IoT Labs Pages 10


7.6. Arduino IDE

- Select Serial Port and Board

IoT Labs Pages 11


- Status Messages

• In the above figure, I have used the simple blink example and I am gonna generate
its hex file.
• Now when you click on the Preferences, a new window will pop up.
• In this new window, tick the compilation option as shown in below figure:

7.7. A Little Bit About Programming


- Code is case sensitive
- Statements are commands and must end with a semi-colon

IoT Labs Pages 12


- Comments follow a // or begin with /* and end with */

7.8. Terminology

7.9. Variables
- boolean (8 bit) – Chứa logic đơn giản là true/false
- byte (8 bit) – Chứa các số không dấu (chỉ chứa số dương không chứa số âm) từ 0-255
- char (8 bit) – Số có dấu từ -128 đến 127. IDE sẽ mặc định dùng biến này để chỉ ký tự
tương ứng trong bảng mã ASCII khi dùng các lệnh, hàm liên quan đến ký tự.
- unsigned char (8 bit) – Tương tự như Byte. Thông thường bạn nên sử dụng Byte để
tránh nhầm lẫn
- word (16 bit) – Số không dấu từ 0-65535
IoT Labs Pages 13
- unsigned int (16 bit)- Tương tự như Word. Bạn nên sử dụng Word để tránh nhầm lẫn.
Tuy nhiên, một số bạn vẫn tiện tay dùng.
- int (16 bit) – Số có dấu từ -32768 đến 32767. Đây là biến thông dụng
- unsigned long (32 bit) – Số không dấu từ 0-4,294,967,295. thường sử dụng để lưu giá
trị trong hàm millis(), đây là hàm trả về giá trị milli giây kể từ khi Arduino bắt đầu
hoạt động.
- long (32 bit) – Số có dấu từ -2,147,483,648 to 2,147,483,647
- float (32 bit) – Số có dấu từ -3.4028235E38 to 3.4028235E38. Dấu chấm động thường
ít được sự dụng trong Arduino vì trình biên dịch rất khó khăn để chuyển đổi thực thi
các lệnh liên quan. Nếu thật sự không quá cần thiết, bạn không nên sử dụng đến nó.
- String – Biến chứa một chuỗi các ký tự (char).
- Void – Chỉ sử dụng để khai báo hàm khi không cần phải trả về bất cứ giá trị nào.
7.10. Digital I/0

- pinMode(pin, mode): Sets pin to either INPUT or OUTPUT


- digitalRead(pin): Reads HIGH or LOW from a pin
- digitalWrite(pin, value): Writes HIGH or LOW to a pin
- Electronic stuff : Output pins can provide 40 mA of current, Writing HIGH to an input
pin installs a 20KΩ pullup
7.11. Arduino Timing
- delay(ms): Pauses for a few milliseconds
- delayMicroseconds(us): Pauses for a few microseconds
7.12. Digital? Analog?
- Digital has two values: on and off
- Analog has many (infinite) values
- Computers don’t really do analog, they quantize
- Remember the 6 analog input pins---here’s how they work
7.13. Important functions
- Serial.println(value);
o Prints the value to the Serial Monitor on your computer
- pinMode(pin, mode);
o Configures a digital pin to read (input) or write (output) a digital value
- digitalRead(pin);
o Reads a digital value (HIGH or LOW) on a pin set for input
- digitalWrite(pin, value);
o Writes the digital value (HIGH or LOW) to a pin set for output
IoT Labs Pages 14
8. Simple Steps to of Arduino code simulator using Proteus
8.1. Write Arduino Codes in Arduino Software IDE
8.2. Configure Arduino Proteus Library Files
We are turning the Proteus as a Simulator for Arduino with the help
of Arduino Preoteus library files.Download Arduino Protius library from here, then
copy and paste the 2 library files (ARDUINO.IDX, ARDUINO.LIB) in to
LIBRARY folder of Proteus.
LIBRARY location of Proteus may be different according to your Proteus
version.
Proteus 8 Users
C:\Documents and Settings\All Users\Application Data\Labcenter Electronics\Proteus
8 Professional\LIBRARY
Proteus 7 Users
C:\Labcenter Electronics\Proteus 7 Professional\LIBRARY
Notes: if you use windows-10, path of following is used:
C:\ProgramData\Labcenter Electronics\Proteus 8 Professional\LIBRARY

8.3. Draw schematics in Proteus


Draw the required schematic diagram of Proteus that you would like to
Simulate, you can choose the Arduino board from the menu.

IoT Labs Pages 15


In our example I’m using LED blinking program and my schematics is
shown below.

8.4. Programming For Push Button With Arduino


To understand the programming of push button use with Arduino, First, you need to
know the input function and its use. Explanation of the input function is given below :
pinMode(pin number, INPUT): I have already discussed pinMode function use
in LED blinking with Arduino UNO R3. The same function is used to declare pin as
an input pin. Where INPUT argument is used to declare the specified pin number as
an input pin. For example pinMode(0, INPUT) function declare pin 0 as a input pin.
digitalRead(pin number):digitalRead function is used to read status of input pin either
pin is at logic level high or logic level low. The output of this function is stored in another
variable which can be used to perform other functions according to your application.
digitalWrite(pin number, HIGH/LOW):digitalWrite function is used to write or output
at specified pin number either output is logic high or logic low.
IoT Labs Pages 16
The code of the above circuit is given below. Copy this code to Arduino software.
int buttonStatus; // Variable declare to store status of digitalWrite
void setup() {
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(0, INPUT);
}
void loop()
{
buttonStatus = digitalRead(0);
if (buttonStatus == HIGH)
{
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
}
else
{
digitalWrite(1, LOW);
digitalWrite(2, LOW);
}
}
8.5. Build .hex file from Arduino Software
Go to File → Preferences

There will be one 2 check box near to ‘Show verbose output during’,
please check the first one.

IoT Labs Pages 17


Now click Compile button.
Compilation yields .hex file, go to the directory location marked above
(may be different location in your case), this is the location of your .hex
file. Copy the file and keep it in a safe location.

IoT Labs Pages 18


8.6. Load the .hex file to Proteus
To load .hex file to the Arduino board, just double click on the board
and browse the .hex file in the Program File section.

Everything is ready to go! Run the Simulation now. You can see the
simulated output of the Arduino Program, watch the video for my
simulation output.
9. Traffic signal control
9.1. circuit in Proteus

IoT Labs Pages 19


10. Lưu file Hex vào vị trí mong muốn
- Bước 1: Mở tập tin C:\Program Files\Arduino\lib\preferences.txt bằng
Notepad hoặc Notepad++
- Bước 2: Thêm dòng lệnh sau vào cuối file preferences.txt: build.path =
<path> (<path> là đường dẫn đến thư mục mà bạn muốn chứa file hex
sau khi Arduino hoàn tất quá trình biên dịch)
- Ví dụ: Để lưu vào thư mục Built_Arduino (mình vừa tạo) trên desktop
của mình, mình viết như sau:

IoT Labs Pages 20


- Sau đó bạn nhớ ấn Ctr + S để Save lại nhé :D
- Tiếp theo bạn tắt IDE đi và mở lại (nhất thiết phải vậy nhé), mở CODE

Blink led nhấp nháy như trên mình trình bày và Verify
- Bạn sẽ thấy file .hex đã không còn ở thư mục temp khó tìm nữa mà vào
đúng thư mục mình mong muốn.

11.

IoT Labs Pages 21

You might also like