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

Module-2-Microcontrollers-and-SBCs

Chapter 2 covers microcontrollers and Single Board Computers (SBCs), focusing on their definitions, applications, and programming using Arduino. It includes objectives for students, vocabulary terms, and guided activities to enhance comprehension through practical exercises. The chapter emphasizes the importance of models in computing and introduces the Arduino platform for hands-on learning in robotics and machine learning.
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)
24 views14 pages

Module-2-Microcontrollers-and-SBCs

Chapter 2 covers microcontrollers and Single Board Computers (SBCs), focusing on their definitions, applications, and programming using Arduino. It includes objectives for students, vocabulary terms, and guided activities to enhance comprehension through practical exercises. The chapter emphasizes the importance of models in computing and introduces the Arduino platform for hands-on learning in robotics and machine learning.
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

CHAPTER 2:

MICROCONTROL
LERS AND SBCs

COMPENG ELEC 2
2nd Sem, SY 2024 -2025
Aubrey Micah C. Dalino

i
Table of Contents
Introduction ........................................................................................................... 1
Objectives .............................................................................................................. 1
Learning Content .................................................................................................... 1
What is SBC?.................................................................................................. 1
VOCABULARY ............................................................................................. 2
Arduino ...................................................................................................... 4
Guided Activity ........................................................................................... 5
1. Serial Port ................................................................................................ 5
2. The Arduino™ Sketch ................................................................................... 6
3. Activity 1: Hello World! ........................................................................... 8
4. Activity 2: Text Formatting! ................................................................... 10
5. Activity 3: Rocket Challenge! ................................................................. 10
Summary .............................................................................................................. 11
Teaching and Learning Activities........................................................................... 11
Recommended Learning Materials and Resources for Supplementary Reading .... 11

ii
CHAPTER 2 – MICROCONTROLLERS AND SBCs
COMP ENG ELEC 2 – ROBOTICS/MACHINE LEARNING 2

Introduction
In this chapter, microcontrollers and SBCs are discussed. Different computing models were explicitly discussed.
New terms were also introduced and described including how they are used in the lesson. At the end of the lesson,
there is a Guided Activity which will be performed by group to check students’ comprehension on the subject.

Objectives
At the end of the topic, the student should be able to:

➢ Explain SBC
➢ Determine the different computing models
➢ Discuss the different functions of terms
➢ Explain computer features and purposes
➢ Perform the Rocket Challenge
➢ Create first Arduino Program

Learning Content
What is SBC?
➢ SBC stands for Single Board Computers
➢ are small computing devices that can be used for a variety of purposes that include experimentation, learning
how to program, building a media player or NAS drive, robotics and home automation, and performing
computing tasks such as web browsing or word processing. SBCs are also increasingly used for a wide
range of industrial applications in areas that include robotics and the Internet of things (IoT)
➢ Arduino is an example of SBC

Robotics is also an application of Computer Science. Computer science is the application of numbers and logic
to make devices, algorithms, and languages that, together, can model just about anything. The table below is the
tools we will be using in this subject.

Table 1. Tools
TOOL DESCRIPTION
Devices The ArduinoTM family of Single-Board Computers (SBCs)
Algorithms The collection of programming techniques, tools and libraries we use to build our models.
Language The C programming language.

1
Table 2. Examples of MODELS in Computing
Example What is modeled How model connects to world
League of Legends A fantasy world where Players (humans) participate by controlling the actions of
characters possess some of the characters. High quality graphics and game
magical and physical play allow the
powers. user to suspend disbelief and pretend the world is real and
that the player is actually the character being controlled.

Digital medical The detailed densities of By collecting data about minute movement of molecules in
imaging via Magnetic the portions of the body response to a changing magnetic field, a model of the
Resonance being scanned. scanned object is created. This model is presented to
the user as startlingly detailed 2D and 3D images of what
would be found if the subject were opened surgically.
Microsoft Word The appearance of The user can add to and modify both the content and
formatted text as if it were appearance of this text and can cause a copy of the model
typed directly onto a piece to be printed on paper.
of paper.

Aircraft Autopilot The stable light of an The computer collects data (speed, direction, physical
aircraft. orientation of the aircraft, altitude) and uses the model to
control wing surfaces and engine speed.

Notice that in each case the computer creates and maintains a model. That model might be something that exists in
reality or something entirely fictional. And the output from the model may be information that appears on a screen,
instructions that control physical devices, or a physical product, such as text or graphics printed on paper or plastic.

The important takeaway is this: all computer programs are models.

The experiments and projects that we will explore in this subject focus on concepts and build models that control
lights, make sounds, run robots, turn motors, detect and compose messages, and more. Some of these models will
collect and respond to data from their environments. Some will provide text as their output, and others will control
physical devices. But every experiment and project are controlled by an Arduino™ running a model of what is being
built. And, that model will be written with the C programming language.

VOCABULARY
In this module, new terms will be defined in the vocabulary section for quick learning reference.

Table 3. Vocabulary
TERM DEFINITION
A means of or steps to performing a specific task. For a computer, an
algorithm
algorithm is usually expressed in a set of computer program instructions.
A single-board computer and an open-source electronics platform based on
Arduino™ easy-to-use hardware and software. It's intended for anyone making
interactive projects.
baud A unit of measure of the speed of data going into and out of a serial port.

2
The programming language used to write sketches for the Arduino™ SBC.
C programming language The syntax is similar to several other commonly used programming
languages, including C++, C#, and Java.
Text inside a sketch that is present to provide the human reader of the
comment sketch insight into some aspect of the sketch's operation but that is ignored by
the Arduino™ as it obeys programming statements.
Finding and fixing improper behaviors in an Arduino™ sketch (and in other
debugging computer programs).
An escape sequence is a pair of characters embedded in text where the
first character is a backslash (\). The second character is a command to do
something special when that text is printed on a computer screen via the
Serial.print() and Serial.println() programming statements.
escape sequence
The second characters are: the double quote ("), used to print the quota tion
mark as text, the lower-case letter t, which advances printing to the
next tab, the lower-case letter n, which moves printing to a new line, and
the backslash character itself (\), which prints the backslash as text.
Integrated Development
Environment (IDE) A collection of computer programs used to create other computer programs.
A word that has a specific and predefined meaning in the C programming
keyword
language.
One of the two essential methods in each Arduino™ sketch. The C-language
loop() method
statements in this method run over and over
A collection of C-language statements that perform a specific task. A
method
method always has a name. Some methods can receive and return data.
A complete self-contained computer in a chip, including the memory for a
microcontroller program and its data. This small microprocessor also contains the necessary
electronics to communicate with external devices.
A complex electronic integrated circuit that performs the processing tasks of a
microprocessor
computer, including input, output, and computation.
output Information of any sort that comes out of a computer.
A computer language instruction. A set of pre-written C-language instruc tions
programming statement
that are used to send and receive data via a serial port.
A set of pre-written C-language instructions that are used to send and
serial library
receive data via a serial port.
A feature of the Arduino™ IDE that allows sending text to and getting text
Serial Monitor
from the sketch running on the Arduino™.
A service built into each Arduino™ specifically to send to and receive data
serial port
from outside devices, including another computer
One of the two essential methods in each Arduino™ sketch. The C-language
statements in this method run only once, when the sketch first starts. These
setup() method
statements initialize the Arduino™, any attached devices, and the sketch itself
prior to running.
single-board computer An entire microcomputer on a single printed circuit board. Abbreviated SBC.
(SBC) Examples include the Arduino™ and the Raspberry Pi.
sketch A computer program written for the Arduino™.

3
Arduino
➢ is an open-source electronics platform based on easy-to-use hardware and software.
➢ Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and
turn it into an output - activating a motor, turning on an LED, publishing something online. You can tell your
board what to do by sending a set of instructions to the microcontroller on the board. To do so you use the
Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on Processing.
➢ Arduino™ is a name given to a family of single-board computers (SBCs). The particular family member
used in lessons in our laboratory exercises is the Arduino™ Uno.
➢ All Arduinos™ contain an integrated circuit called a microcontroller.
o A microcontroller is a small but complete microprocessor capable of input, output, and
computation. In addition, a microcontroller includes storage memory for a computer program and
its data.

➢ Surrounding this microcontroller are the electronic components, connectors, and rows of sockets necessary
to bring power to the microcontroller, allow it to receive information from the outside world, and to transmit
information.
➢ The term single-board means that the entire computer fits on a single circuit board. Different members of
the Arduino™ family have different features. Some are small and light enough to be sewn into clothing, while
others are sufficiently powerful to perform complex tasks very quickly. But they are a family in that they are
all programmed with the same language. he syntax of this language is so very close to C that it is referred
to as the C language. Mastery of this language serves as an excellent base for other commonly used
programming languages, including C++, C#, and Java.
➢ The laboratory exercises associated with this learning module allows student to begin with the installation
and testing of the set of computer programs used to write and install Arduino™ sketches. This collection of
computer programs is called the Arduino™ Integrated Development Environment (IDE). A program
written for the Arduino™ is called a sketch.

4
➢ An Arduino™ can be programmed to send messages to and receive messages from the computer being
used to write and upload sketches. A feature called the serial port makes this communication possible. The
next section shows how to use the serial port to send messages from an Arduino™ sketch and to use a
feature of the Arduino™ IDE called the Serial Monitor to view those messages.

Table 4. Computer Features, Purposes and Examples


Feature Purpose Examples
Input To receive information from the Keyboard, mouse, network connection, touch
outside world. screen, voltage sensor
Output To display information or to control Monitors, lights, printer, motor, network
devices connection
Processor To manipulate information. Intel Core i5, Atmel ATmega 328

Storage To contain programs to be run and Memory, hard disk, cloud storage.
data to be accessed.

Guided Activity
• Together with your formed grouping, review the succeeding part and perform the tasks needed.

1. Serial Port
o The Arduino™ is a complete computer possessing each of the features listed in Table 4.
o In this lesson, you will have the opportunity to write your first Arduino™ sketches.
o The sketches take advantage of the output ability of the Arduino™ to send text messages to the
Arduino™ Integrated Development Environment (IDE) via a built-in serial port. his port is composed
of some electronic components specifically designed to send data to and receive data from another
device, in this case a computer via USB, some special hardware designed to communicate text.
o The port can also send data out pin 1 of the Arduino™ and receive it via pin 0. These pins are
marked TX for transmit and RX for receive.

o The ability of the port to transmit and receive data is very handy. It is especially useful for discovering
why sketches don't always operate as expected. The process of fixing things that are wrong with a

5
sketch is called debugging. A common technique for debugging is building into a sketch the
sending of text messages to the IDE.

2. The Arduino™ Sketch


o To make use of the serial port, or any other feature of the Arduino™, a sketch is required.
o A sketch is a collection of instructions for your Arduino™. A specific instruction within a sketch is
called a programming statement. An example of a statement is shown in Example 2-1.

o The programming statement in Example 2-1 instructs the Arduino™ to send the word "Hello" out
the serial port. Statements that, taken together, perform a specific task may be grouped and named.
Such a group is called a method.
o A method is a collection of programming statements that, when executed in order, perform some
subtask essential to the overall purpose of the sketch. If the sketch operates a robot, for example,
one subtask is to detect surrounding obstacles. Another subtask controls motors. Yet another
detects and decodes messages from a remote control. Each of these subtasks appears in the
sketch as a method. Each method has a name, parameters, a return type, and some programming
statements.

o Example 2-2 is an Arduino™ method that might be found within a sketch. his particular method has
parameters: the length and width of a rectangle. It has a return type of int, meaning integer, because
the method "returns" the calculated area. (The use of return values is included in a later lesson.)

6
o All methods comply with this format. If a method does not have parameters, then empty parentheses
are used in the name. (A parameter is a special kind of variable used by a method to refer to data
provided as input.) If no values are to be returned, then the return type is void. Example 2-3 is an
Arduino™ method that has no parameters and no values returned. This method merely plays some
sounds.

o Every Arduino™ sketch must use, at a minimum, the two methods listed in Table 5.

Table 5. Methods required in every ArduinoTM sketch


METHOD WHAT THE STATEMENT DOES RETURN TYPE
setup() Initializes the ArduinoTM and its components void
loop() Performs a task void

o Both setup() and loop() have void as the return type (or type of data that the method yields) because
neither ever has any values to return. Neither method has any parameters, which is why their names
are followed by empty parentheses. To help other people understand what you, the programmer,
have done and when and to aid you when you revisit a sketch, you can embed notes within a sketch.
These notes have nothing to do with how the sketch works; they are for information only.
o One way of entering a note is to begin with a pair of slashes. When the Arduino™ is executing
programming statements, it ignores anything following a pair of slashes. he following programming
statement has a note:

o Another method of entering a note is to use slash-asterisk bookends: /* and */. The content between
them becomes a comment, and the Arduino™ ignores the comment when it is carrying out
programming statements.

7
o Finally, some words have special meaning to the C language as it is used with the Arduino™. These
are called keywords. A keyword cannot be used for any other purpose. he programming statement
delay() uses the keyword delay.
o Other commonly used keywords are:
double signed case
int if break
switch goto false
void for true
while else short
long do char
return const

o In this lesson you will create the sketch shown in Sketch 2-1. Note the comments, methods, and
programming statements.

3. Activity 1: Hello World!


o Begin by connecting your Arduino board to your computer.
o Create a 3-line comments where;
▪ First Line: your sketch name which is “MyFristArduinoSketch.ino”
▪ Second Line: Group Number

8
▪ Third Line: Date this guided activity is performed.

o Enter the programming statements for the setup() method. This method runs when the Arduino™
is first started.
o Next add the loop() method. This method runs over and over and over and over — continuously
repeating the programming statements. In this case the loop() method is sending the message
Hello, world!repeatedly to the Serial Monitor. The programming statement delay(500)
pauses the Arduino™ for 500 milliseconds (one-half a second).
o Save your sketch then Compile and Upload to the board.
o Open the Serial Monitor by click ing Serial Monitor under the Tools menu

o The words "Hello, world!" should be scrolling through the text win dow in the Serial Monitor. If they
are not, make certain the box marked Autoscroll is checked. Check the baud rate that appears in
the Combo Box at the lower right. It should be set to 9600, the rate used in the Serial.begin(9600)
statement in the setup method. Baud is a measure of data transfer speed.

9
4. Activity 2: Text Formatting!
➢ Perform the tasks listed in Table 6 and record your observations in its right-hand column.

Table 6. Observation Table


TASK OBSERVATION
1. Replace the Serial.println command
with:Serial.println("test");
2. Replace the word println with print.
3. Add a second double quote.
Serial.print("test \"");

Note: The \ (backslash) character followed by the quotation


mark is called an escape sequence. It allows for the
quotation mark to be printed rather than interpreted as the
end of the text.
4. Replace the second quote with a second
backslash.
Serial.print("test \\");
5. Replace the second quote with a second
backslash.
Serial.print("test \\");
6. Use what you have learned to cause the words
"Snoopy is a dog." to be printed, including the
quotation marks.
Write the new statement in the box to the right.

5. Activity 3: Rocket Challenge!


➢ Create a new sketch named “Rocket” and then create the program that will display a rocket just as
below. Screenshot your Serial Monitor output and copy your program to your answer sheet.

10
Summary
In this chapter, students were introduced the concepts of Microcontrollers and SBCs. There were also different
computing models applications but for this subject, the important takeaway is this: all computer programs are models.
Throughout the lesson, there were term introduced which was summarized on the vocabulary section. The Guided
Activity allows students to fully comprehend the Arduino environment in preparation for the conduct of the proposed
projects.

Teaching and Learning Activities

Assessment 2/ Quizzes 2-5: GUIDED ACTIVTY

➢ Review the Guided Activity section of the lesson. Perform the tasks and create a
separate document file to compile all your answers.
➢ Make sure to add your names, group number and date the activity is submitted.
➢ Your answer sheet should contain the programs and screenshot of the output of your
Serial Monitor. (Activity 1 & 2: 5 points each. Activity 3: 10 points each)
➢ Save your files as PDF and submit your outputs in the Chapter 2 Learning Activity
Submission Portal until March 27, 2025, 12PM.
NOTE: If your file is not in PDF, your output will be marked zero.

Recommended Learning Materials and Resources for Supplementary Reading

Books:
➢ Ceceri, Kathy (2012). Making Simple Robots. Maker Media, Inc.
➢ Joseph, Lentin (2018). Robot Operating System for Absolute Beginners: Robotics Programming Made
Easy. New York: Springer Science + Business Media Finance Inc(SSBM Finance Inc)

Online Resources:
➢ https://epsrc.ukri.org/research/ourportfolio/themes/engineering/activities/principlesofrobotics/
➢ https://www.sciencebuddies.org/science-fair-projects/engineering-design-process/engineering-
design-process-steps
➢ https://builtin.com/robotics
➢ https://www.nasa.gov/audience/forstudents/5-8/features/nasa-knows/what_is_robotics_58.html
➢ https://learn.g2.com/what-is-robotics
➢ https://www.eletimes.com/the-perennial-role-of-analog-electronics
➢ https://www.fool.com/the-blueprint/project-proposal/

11
12

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy