0% found this document useful (0 votes)
4 views14 pages

Introduction to Arduino Basics Lec-02 UETFSD

Arduino

Uploaded by

anasjaveed739
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)
4 views14 pages

Introduction to Arduino Basics Lec-02 UETFSD

Arduino

Uploaded by

anasjaveed739
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/ 14

Introduction to Arduino Basics

Lecture 02
Introduction to Arduino Programming

Presented By
Engr. Abdullah Bilal
Department of Electrical, Electronics & Telecommunication
UET Lahore, Faisalabad Campus
OBJECTIVES
▪ Understand Arduino IDE and its features

▪ Learn the basic structure of an Arduino sketch

▪ Explore basic syntax and functions

▪ Write and upload your first program

▪ Learn about data types, commands, and pin functionalities


WHAT IS ARDUINO IDE?
▪ IDE = Integrated Development Environment

▪ Used to write, compile, and upload code to Arduino boards

▪ Free and open-source

▪ Available on Windows, Mac, and Linux

▪ Supports various boards (UNO, Nano, Mega)


INSTALLING AND SETTING UP ARDUINO IDE
▪ Download from: https://www.arduino.cc

▪ Install and open the IDE

▪ Connect Arduino board via USB

▪ Set up in Tools menu:

▪ - Board: Arduino UNO

▪ - Port: COMx (check device manager)

▪ - Programmer: AVRISP mkII


STRUCTURE OF AN ARDUINO SKETCH
▪ void setup() {
▪ // Code that runs once
▪}

▪ void loop() {
▪ // Code that runs repeatedly
▪}
▪ - setup(): Called once at the beginning
▪ - loop(): Repeats forever
BASIC FUNCTIONS
▪ pinMode(): Sets a pin as INPUT or OUTPUT

▪ digitalWrite(): Sends HIGH or LOW to digital pin

▪ digitalRead(): Reads HIGH or LOW from a digital pin

▪ analogRead(): Reads analog value (0-1023)

▪ analogWrite(): Sends PWM signal (0-255) to a pin

▪ delay(ms): Waits for given milliseconds


DATA TYPES IN ARDUINO
▪ int: Integer (-32,768 to 32,767) e.g., int x = 10;

▪ float: Decimal number e.g., float temp = 25.5;

▪ char: Single character e.g., char ch = 'A';

▪ boolean: true or false e.g., boolean flag = true;

▪ String: Sequence of characters e.g., String name = "Ali";


SYNTAX RULES
▪ Case-sensitive (e.g., DigitalWrite is wrong)

▪ Statements end with a semicolon (;)

▪ // Single line comment

▪ /* Multi-line comment */

▪ Curly braces {} define code blocks


YOUR FIRST PROGRAM – BLINK LED
void setup() {
pinMode(13, OUTPUT);
}

void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
NEXT CLASS PREVIEW
▪ Getting started with Tinkercad.
▪ Write and upload your first program (Blink).
▪ Learn code structure: setup() and loop().

You might also like