Lab 2 - Introduction To Arduino & Its Coding
Lab 2 - Introduction To Arduino & Its Coding
Introduction to Arduino
Lab. Experiment # 2
Objective:
To understand structure of Arduino.
Understanding Coding of Arduino.
Digital Inputs, Outputs, and Pulse-Width Modulation.
Getting Up and Blinking with the Arduino.
Objective:
Arduino is an open source physical computing platform based on a simple input/output (I/O)
board and a development environment that implements the Processing language.
Unique Features:
Arduino is different from other platforms on the market because of these features:
Arduino Components:
All Arduino boards have a few key capabilities and functions. Take a moment to examine the
Arduino Uno in Figure 1.
Atmel microcontroller
USB programming/communication interface(s)
Voltage regulator and power connections
Breakout I/O pins
66 | P a g e Department of Electrical & Computer Engineering | CUI Wah
EEE342 - Microprocessor Systems and Interfacing
After completing the download, unzip it. Inside, you’ll find the Arduino IDE. New versions of the
Windows IDE are available as an installer that you can download and run, instead of downloading
a ZIP file.
Mac and Linux machines install the drivers (mostly) automatically. If you are using OS X, the first
time you plug in an UNO or a Mega 2560, you will get a notification that a new network device
has been added. Click the Network Preferences button. In the new window, click Apply. Even
though the board will appear as “Not Configured” in the network device list, it will be ready to
use. Now, quit System Preferences. If you are using a modern Arduino on a Windows computer,
you will probably need to install drivers. You can skip the following directions if you are not using
a Windows computer that needs to have drivers installed. If you installed the IDE using the
Windows installer, then these steps have been completed for you. If you downloaded the ZIP on
your Windows machine, then you will need to follow the directions shown next.
Now, launch the Arduino IDE. You’re ready to load your first program onto your Arduino.
To ensure that everything is working as expected, you’ll load the Blink example program, which
will blink the onboard LED.
Lab Tasks
Task 1:
Write following code and observe behavior of LED. (Connect +ve leg of LCD to pin 7 and –ve leg
to ground).Write delay in seconds for which LED remains ON and then turns OFF.
int led1=7; //connect +ve leg of LED on pin7
void setup()
{
pinMode(led1,OUTPUT); //setting LED as output
}
void loop()
{
digitalWrite(led1,HIGH); //setting LED ON
delay(1000);
digitalWrite(led1,LOW); //setting LED OFF
delay(1000);
}
Task 2:
Write a code such that LED remains ON for 2 seconds and then turns OFF for 1 second, also attach
proteus schematic.
Task 3:
Write a code such that LED should remain ON till the pushbutton is pressed, once pushbutton is
released, LED should go OFF, also attach proteus schematic for both cases.
Task 4:
Write a code to fade the LED in and out using Pulse Width Modulation (PWM).