0% found this document useful (0 votes)
13 views

GEC225 Module6 - Arduino

This document provides an outline for a course on Arduino C & interfacing with the outside world. It begins with an introduction to the C programming language and covers data types, operators, decision making, loops, functions, pointers, structures, and object-oriented programming. It then provides an overview of Arduino, including its advantages, common microcontrollers, boards, shields, and IDE. Examples are given to illustrate how to write, compile, and upload code to produce outputs like blinking an LED. The goal is to teach students how to use C to program Arduino boards and interface with external components.

Uploaded by

Sosanwo Samuel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

GEC225 Module6 - Arduino

This document provides an outline for a course on Arduino C & interfacing with the outside world. It begins with an introduction to the C programming language and covers data types, operators, decision making, loops, functions, pointers, structures, and object-oriented programming. It then provides an overview of Arduino, including its advantages, common microcontrollers, boards, shields, and IDE. Examples are given to illustrate how to write, compile, and upload code to produce outputs like blinking an LED. The goal is to teach students how to use C to program Arduino boards and interface with external components.

Uploaded by

Sosanwo Samuel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

www.covenantuniversity.

Raising a new Generation of Leaders

ARDUINO C & Interfacing


with the Outside World
Course Outline
• Introduction to Linux Operating System, Installation, Understanding
Ubuntu Desktop, Basic Command and Security Concept.
• Understand C Language Overview and Program Structure, and Data
types.
• Fundamentals of C Operators and Escape Sequence
• Decision making in C
• Program Loops in C
• Use Functions in C
• Understand Storage Classes and Scope
• Understand Pointers and Use Pointers Effectively
• Create Structures, Unions and Data Storage
• Arduino C and Interfacing with the Outside World
• Understand the basics of Object Oriented Programming such as C++ 2
1.0 Introduction to Arduino
• Arduino is an open-source electronics platform based
on easy-to-use hardware and software, developed in
order to simplify the process of working with
microcontrollers.
• The advantages of using Arduino over other similar
systems are:
i) Inexpensive: Some Arduino modules cost less than
$50.
ii) Open source and extensible hardware: Arduino
board plans are published under a Creative
Commons license, which allows electronic
designers to extend and improve on it.

3
iii) Cross-platform: Arduino Software Integrated Development
Environment runs on Windows, Mac and Linux operating
systems.
iv) Open source software: Arduino IDE is published as open
source tools, which can be extended by experienced
programmers through C++ libraries.
v) Simple and clear programming environment: Arduino IDE
is easy-to-use for beginners and also flexible for advanced
programmers.

4
2.0 Microcontrollers and the Arduino
board
• A microcontroller(µC or MCU) is a
computer on a single integrated
chip that contains:
 Processor
 Memory: RAM, ROM and Flash memory
 I/O ports: USB, Ethernet, Inter-Integrated Circuit
(I2C) and Serial Peripheral Interface (SPI).

5
• The most common microcontroller
families are Intel(4004,8008, 80286), Atmel(AT
and AVR), Microchip(PIC) and ARM(Cortex-A,
Cortex-M)

6
• Atmel microcontrollers(shown in Table 1) are
commonly used in Arduino boards.

Table 1: Some microcontrollers used on arduino boards


µC Flash SRAM EEPROM Clock Digital Analog Voltage
memory (bytes) (bytes) speed I/O pins input pins
(bytes)

ATmega168 16K 1K 512 16Mhz 14 6 5V

ATmega328 32K 2K 1K 16Mhz 14 6 5V

ATmega1280 128K 8K 4K 16Mhz 54 16 5V

ATmega2560 256K 8K 4K 16Mhz 54 16 5V

7
• Arduino has several brands which
include - Arduino Uno, Arduino Yun, Arduino
Leonardo, Arduino LilyPad, Arduino Mega,
Arduino Nano, Arduino Mini, Arduino Mini Pro,
Arduino BT

8
• Arduino also have shields, which
can be plugged on top of the
Arduino PCB to extend its
capabilities. Examples of Arduino
shields are: Motor shield, TFT touch screen
shield, Ethernet shield, GSM shield, WiFi
shield, eHealth shield and etc.

9
A sample project with Arduino and motor shield

10
• The different parts of an Arduino
board are shown below:

11
3.0 Arduino IDE
• Just like other computers, any MCU
requires program instructions to
work.
• The Arduino IDE is a software that
contains all you need to write
program codes.
• The Arduino programming language
that you write in the IDE is a
simplified version of C language.
12
• The elements of the IDE are:
 Text editor: for code writing, syntax
and keyword coloring, automatic
indentation
 Compiler: for source code
compilation.
 Hardware interface: to upload
programs and communication with
Arduino board through USB.

13
3.1 Installing Arduino IDE on Linux
Step1: Download the latest package for Linux 32-bit
or Linux 64-bit from:
www. arduino.cc/en/Main/Software
Step 2(a): Open the terminal and navigate to your
downloads folder
cd ~/Downloads
(b) Decompress the downloaded archive with the
command:
tar –xvf arduino-nightly-linux64.tar.xz
(c) Move the result folder to /opt/ directory for
global access:
sudo mv arduino-nightly/opt

14
Step 3 (a): Navigate to install folder
cd /opt/arduino-nightly
(b) Give executable permission to install.sh
script in that folder:
chmod +x install.sh
Step 4 (a) Plug in your board using USB cable and
note that external power is unnecessary.
(b) Run arduino
./arduino

15
3.2 Arduino IDE

16
3.3 Selecting the right arduino board

17
3.3 Selecting the right port

18
3.4 Arduino IDE Command Icons

19
3.5 Arduino Code Structure
• There are two major blocks in the text
area of Arduino IDE.
i) void setup(): The code written in
this block is executed only when the
program begins or reset button is
pressed.
ii) void loop(): The code written inside
this block will be executed
repeatedly.
• Note that programs are called
sketches in Arduino.
20
Example 1: Open your IDE and type
the “Hello World” code:

21
Click the Compile and then the
Upload icons in order to compile
the program and load on the
Arduino board.
Click the Serial Monitor button to
see the code as shown:

22
23
Example 2: Open the LED blink
code example in the IDE as follows:

24
The code is shown in the IDE as follows

25
Compile and upload the code to
obtain:

26
Exercise
Run the Fade code example in the
IDE(File>Examples>Basics>Fade).

27
www.covenantuniversity.

Raising a new Generation of Leaders

Thank you.

You might also like