0% found this document useful (0 votes)
36 views16 pages

Lecture 02

The document outlines the course for an Arduino based system design course, which will teach students how to program an Arduino board to take inputs from various sensors and control outputs like LEDs and motors through developing control logic. It also covers interfacing electronic components with the Arduino, and writing software with the necessary control logic to accomplish tasks. The document provides references for learning Arduino and describes important Arduino functions for digital and analog I/O, time, and serial communication.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views16 pages

Lecture 02

The document outlines the course for an Arduino based system design course, which will teach students how to program an Arduino board to take inputs from various sensors and control outputs like LEDs and motors through developing control logic. It also covers interfacing electronic components with the Arduino, and writing software with the necessary control logic to accomplish tasks. The document provides references for learning Arduino and describes important Arduino functions for digital and analog I/O, time, and serial communication.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

ECE 2030

Arduino Based System


Design

Daw Khaing Su Wai


Course Outlines
1. Learn how to program the Arduino to do various simple tasks.
2. Taking in inputs from various sensors.
3. Develop control logic in the program to control the environment though LEDs,
actuators or motors, etc.
4. Learn how to interface different electronic components, LEDs, sensors, motors
with the Arduino board.
5. And, write software that runs on the Arduino which has all the control logic
needed to accomplish a task .
References

1. Arduino Cook Book, by Michael Morgolis, 2nd Edition – O’REILLY.


2. Introduction to Arduino, by Alan G Smith, 30 Sep 2011
3. Make: Getting Started with Arduino, 3rd Edition, Massimo Banzi
Structure, Syntax and Operator
Arduino Program Structure

setup : It is called only when the Arduino


is powered on or reset.
• It is used to initialize variables and pin
modes
loop : The loop functions runs
continuously till the device is powered
off.
• main logic of the code goes here.
Arduino Specific Functions
Arduino Specific Functions
Digital I/O
1. digitalRead()
• Description: Read the value from a specific digital pin ,either HIGH or LOW
• Syntax: digitalRead(pin)
• Parameter: The Arduino numbers you want to read
2. digitalWrite()
• Description: Write a HIGH or LOW value to a digital pin
• Syntax: digitalWrite(pin , value)
• pin: the Arduino pin number
• value : HIGH or LOW
3. pinMode()
• Description: Configures the specific pin to behave either as an input or output.
• Syntax: pinMode( pin , mode)
• pin: the Arduino pin number
• mode : INPUT or OUTPUT
Arduino Specific Functions

PinMode
A pin on arduino can be set as input or output by using pinMode function.
• pinMode(ledPin, OUTPUT); // sets pin 13 as output pin
• pinMode(ledPin, INPUT); // sets pin 13 as input pin
Reading/writing digital values
digitalWrite(ledPin, LOW); // Makes the output voltage on pin 13 , 0V
digitalWrite(ledPin, HIGH); // Makes the output voltage on pin 13 , 5V
Arduino Specific Functions
Arduino Specific Functions
Analog I/O
1. analogRead()
• Description: Read the value from the specific analog pin. Arduino boards contain a multichannel, 10-bit analog
to digital converter.
• This means that it will map input voltages between 0 and the operating voltage (5V or 3.3V) into integer values
between 0 and 1023.
• Syntax: analogRead(pin)
• Parameter:the name of the analog input pin to read from (A0 to A5)
2. analoglWrite()
• Description: Write an analog value to a pin. Can be used to light a LED at varying brightness or drive a motor at
various speeds.
• Syntax: analogWrite(pin , value)
• pin: the Arduino pin to write to : Allowed data type : int
• value : the duty cycle between 0 and 255 : Allowed data type : int
3. analogReference()
• Description: Configures the reference voltage used for analog input. The options are
• DEFAULT : the default analog reference of 5 volts or 3.3 volts
• EXTERNAL : the voltage applied to the AREFpin (o to 5V only) is used as the reference
• Syntax: analogReference(type)
Arduino Specific Functions
Arduino Specific Functions
Time
1. delay()
• Description:Pauses the program for the amount of time(in milliseconds) specified as parameter.
• Syntax: delay(time)
• ms: the number of milliseconds to pause. Allowed data type : unsigned long
• Communication
Serial
• Description : Used for communication between the Arduino board and a computer or other
devices. All Arduino boards have at least
• one serial port and some have several.
1. Serial.available()
• Description: get the number of bytes available for reading form the serial port.
• Syntax: Serial.available()
2. Serial.begin()
• Description : Sets the data rate in bits per second for serial data transmission.
• Syntax : Serial.begin(speed)
Arduino Specific Functions
3. Serial.println()
• Description : prints data to the serial port as huma-redable ASCII text followed by
a carriage return character and a new line character.
• Syntax : Serial.println(val)
• Serial : serial port object.
• val : the value to print. Allowed data type : any data type
4. Serial.read()
• Description : Reads incoming serial data
• Syntax : Serial.read()
5. Serial.write()
• Description : Writes binary data to the serial port .
• Syntax : Serial.write(val)
• Serial.write(str)
Arduino Specific Functions
Arduino Data Types
Arduino Data Types

You might also like