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

Arduinofinal 210524112613

COMPUTER

Uploaded by

bgjt.susovan
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 views51 pages

Arduinofinal 210524112613

COMPUTER

Uploaded by

bgjt.susovan
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/ 51

Programming

Logic
and
Design
By: Froilan G. Cantillo

President Ramon Magsaysay State University Computer Engineering Department 1


INTRODUCTION OF COMPUTER PROGRAMMING

Computer Program – Is a list of instructions that the computer machine Three types of applications programs translate from source code to object
follows to properly accept input, correctly process them and present the code:
results in the most understandable way.
• Compilers – Computer software that translates (compiles) source code
Computer Programming – is considered to be an art and at the same written in a high-level language (e.g., C++) into a set of machine-
time a science. It is an art because there is no standard way to interpret a
problem and solve it using a standard form of programming procedures language instructions that can be understood by a digital computer's
and styles. It is fast becoming a science because standard programming CPU. Compilers are very large programs, with error-checking and other
practice is starting to be adopted. abilities
• Interpreters – Is a computer program that directly executes instructions
written in a programming or scripting language, without requiring them
Programs fall into two major classes: previously to have been compiled into a machine language program. An
• Application Programs – application program is one that carries out interpreter generally uses one of the following strategies for program
some function directly for a user, such as word processing or game- execution:
playing. o Parse the source code and perform its behavior directly;
• Operating Systems – operating system is a program that manages the o Translate source code into some efficient intermediate
computer and the various resources and devices connected to it, such representation and immediately execute this;
as RAM (random access memory), hard drives, monitors, keyboards,
printers, and modems, so that they may be used by other programs. o Explicitly execute stored precompiled code made by a compiler
which is part of the interpreter system
A programmer uses another type of program called a text editor to write
the new program in a special notation called a programming language. • Assemblers – Is a program that converts assembly language into
With the text editor, the programmer creates a text file, which is an ordered machine code. It takes the basic commands and operations from
list of instructions, also called the program source file. The individual assembly code and converts them into binary code that can be
instructions that make up the program source file are called source code. recognized by a specific type of processor. Assemblers are similar to
At this point, a special applications program translates the source code compilers in that they produce executable code
into machine language, or object code — a format that the operating
system will recognize as a proper program and be able to execute.

Programming Logic and Design By: Froilan G. Cantillo 2


INTRODUCTION OF COMPUTER PROGRAMMING

Computer is composed of: The following are standard Operating System functions.
1. CPU (Central Processing Unit) – this is where all mathematical and • Validating user identification every time the user uses the computer
logical forms of processing are done on data.
• Provides standard functions like editor, compilers and linkers
2. Memory – before a computer can do any productive work such as
programming, it has to remember things such as data it needs to • Manages files of the user by providing functions like Copy, Delete,
produce information. Append
3. Input and Output Device – data have to come into the computer by
first entering them through input devices. Ex. Keyboard. After the • Retrieves data out of data files
computer executes a program to process data and produce
information, this information remains in the memory. Part of the • Manages memory for the user by determining where in the memory a
program has to show these results to the outside world. Output devices program is to be loaded every time it is called to run
such as monitor screen and printers are used to display the results to
the user. • Makes communication between the CPU, Memory and input/output
devices transparent to the user or the user are unaware of these things
4. Software – computers today come bundled with some software while they are at work.
already installed in them. Operating System – performs for the
programmer many tasks that used to be very difficult to program

Two forms of Memory


• Internal Memory (RAM-Random Access Memory) – stores programs
and data that are executed and processed by the computer.
• Secondary Memory – supplements RAM so those computers are able
to permanently save programs and data that are not yet needed for
execution and processing. Ex. Floppy disk, hard disk & etc.

Programming Logic and Design By: Froilan G. Cantillo 3


INTRODUCTION OF COMPUTER PROGRAMMING

High level languages • Pascal and C – are general-purpose language. They are high-level
language but they can be embedded with assembly language code
• Programming languages that are closer to human language than to effectively making these languages middle-level languages. C language
machine language. They are characterized to use common English is responsible in the implementation of major software including
words as their instructions. Aside from that, high level languages have operating systems, compilers and software development tools
the following characteristics:
• Requires additional step of compilation or translation so that from high-
level, another program that has exactly the same meaning and intended The Simplest computer programs perform three basic operations:
results in low-level or machine language can be generated and loaded
into the computer and executed. • Get the input from the keyboard.

• A compiled program is usually not as efficient as when the program was • Process the input data.
originally written in machine language or assembly. This is due to the
fact that compilers add a lot of extra overheads in terms of memory and • Display the results on the screen.
non-optimized logical translations.

Each of these programming languages was designed to solve particular DISPLAY ALL
kinds of problems. INPUT DATA PROCESS DATA
RESULT
• COBOL – Common Business Oriented Language was designed to
solve business problems like accounting.
• FORTRAN – Formula Translation is a high level language used for
scientific and engineering applications.

Programming Logic and Design By: Froilan G. Cantillo 4


COMPUTER LANGUAGE

Programming Language Classification of Programming Language


• A programming language is a set of rules that provides a way of telling a Programming Languages - Generations
computer what operations to perform.
• High level languages
• A programming language is a set of rules for communicating an o 4th Generation Data query, analysis and reporting
algorithm
o 3rd Generation Imperative
• It provides a linguistic framework for describing computations
• Low level languages
• The grammatical rules are called syntax. o 2nd Generation Assembly
• Each programming language has a different set of syntax rules. o 1st Generation Machine code

Why are there so many programming languages?


• Programming languages have evolved over time as better ways have
been developed to design them.
o First programming languages were developed in the 1950s.
o Since then thousands of languages have been developed.
• Different programming languages are designed for different types of
programs.

Programming Logic and Design By: Froilan G. Cantillo 5


COMPUTER LANGUAGE

Low-Level Language: • Disadvantages


• Machine code and Assembly code o More difficult to understand, maintain and debug than high level
languages.
High-Level Language: o More difficult to write without making errors.
• A programming language that allows programs to be written using o Machine dependent making it difficult to port to a different
English keywords and is platform independent instruction set processor Memory addresses and operations
have to be remembered Low Level Languages.

Low-Level Language:
• Advantages
o Achieves a smaller memory footprint (compact).
o Achieves better code optimization and therefore code will run
faster and more efficiently.
o Allows direct manipulation if the registers on the processors,
giving high levels of control.
o Processors in these systems may be slow and have limited
memory so the efficiency of assembly language or machine code
is needed. Also useful real time control systems where speed is
very important.
o Since you are writing at machine level you control the level of the
code created.
o Can be easily modified.

Programming Logic and Design By: Froilan G. Cantillo 6


COMPUTER LANGUAGE

What are the types of programming languages? Third Generation Languages


• First Generation Languages • Closer to English but included simple mathematical notation.
• Second Generation Languages o Programs written in source code which must be translated into
machine language programs called object code.
• Third Generation Languages o The translation of source code to object code is accomplished by
• Fourth Generation Languages a machine language system program called a compiler.

• Fifth Generation Languages • Alternative to compilation is interpretation which is accomplished by a


system program called an interpreter.
• Common third generation languages
First Generation Language o FORTRAN
• Machine language o COBOL
o Operation code – such as addition or subtraction. o C and C++
o Operands – that identify the data to be processed. o Visual Basic
o Machine language is machine dependent as it is the only language the
computer can understand. Fourth Generation Languages
o Very efficient code but very difficult to write. • A high level language (4GL) that requires fewer instructions to
Second Generation Languages accomplish a task than a third generation language.

• Assembly languages • Used with databases


o Symbolic operation codes replaced binary operation codes. o Query languages
o Assembly language programs needed to be “assembled” for execution o Report generators
by the computer. Each assembly language instruction is translated into
one machine language instruction. o Forms designers
o Very efficient code and easier to write. o Application generators
o Does the world need new languages?

Programming Logic and Design By: Froilan G. Cantillo 7


COMPUTER LANGUAGE

Fifth Generation Languages Traditional Programming Language


• Declarative languages • FORTRAN
• Functional(?): Lisp, Scheme, SML o FORmula TRANslation.
o Also called applicative o Developed at IBM in the mid-1950s.
o Everything is a function o Designed for scientific and mathematical applications by
scientists and engineers.
• Logic: Prolog
• COBOL
o Based on mathematical logic
o COmmon Business Oriented Language.
o Rule- or Constraint-based
o Developed in 1959. ◦ Designed to be common to many different
computers.
Beyond Fifth Generation Language o Typically used for business applications.

• Though no clear definition at present, natural language programs • BASIC


generally can be interpreted and executed by the computer with no o Beginner’s All-purpose Symbolic Instruction Code.
other action by the user than stating their question.
o Developed at Dartmouth College in mid 1960s.
• Limited capabilities at present. o Developed as a simple language for students to write programs
with which they could interact through terminals.
• C
The principal paradigm
o Developed by Bell Laboratories in the early 1970s.
• Imperative Programming (C) o Provides control and efficiency of assembly language while
having third generation language features.
• Object-Oriented Programming (C++)
o Often used for system programs. ◦ UNIX is written in C.
• Logic/Declarative Programming (Prolog)
• Functional/Applicative Programming (Lisp)

Programming Logic and Design By: Froilan G. Cantillo 8


COMPUTER LANGUAGE

Object-Oriented Programming Language Special Programming Language


• Simula • Scripting Languages
o First object-oriented language o JavaScript and VBScript
o Developed by Ole Johan Dahl in the 1960s. o Php and ASP
• Smalltalk o Perl and Python
o First purely object-oriented language. • Command Languages
o Developed by Xerox in mid-1970s. o sh, csh, bash
o Still in use on some computers. • Text processing Languages
• C++ o LaTex, PostScript
o It is C language with additional features. • HTML
o Widely used for developing system and application software. o HyperText Markup Language.
o Graphical user interfaces can be developed easily with visual o Used on the Internet and the World Wide Web (WWW).
programming tools.
o Web page developer puts brief codes called tags in the page to
• JAVA indicate how the page should be formatted.
o An object-oriented language similar to C++ that eliminates lots of • XML
C++’s problematic features.
o Extensible Markup Language.
o Allows a web page developer to create programs for applications,
called applets that can be used through a browser. o A language for defining other languages.
o Objective of JAVA developers is that it be machine, platform and
operating system independent.

Programming Logic and Design By: Froilan G. Cantillo 9


BRIEF HISTORY OF PROGRAMMING LANGUAGE

• 1842- 1843 (First Computer Program created by Ada Lovelace • 1959 COBOL (COMMON BUSINESS- ORIENTED LANGUAGE)
o Work on the Charles Babbage’s analytical engine. A complete CREATED BY SHORT RANGE COMMITTEE)
detail a method for calculating Bernoulli numbers with the engine o High-level. Primarily for business computing. First programming
language to be mandated by the US Department of Defense.
• 1890 Census data on punch cards encoded by Herman Hollerith Primary Uses: Business software (esp. finance and
administration systems, but also banks, insurance agencies,
• 1943-1945 (PLANKALKÜL DEVELOPED FOR THE GERMAN Z3 BY governments, military agencies) Used By: Credit cards, ATMs
KONRAD ZUSE) *Fun Fact Action movie The Terminator used samples of Cobol
o An early high-level programming language to be designed for a source code for the text shown in the Terminator’s vision display.
computer but was not implemented.
• 1964 BASIC (BEGINNER’S ALL-PURPOSE SYMBOLIC
• 1949 (SHORT CODE DEVELOP BY JOHN MAUCHLY) INSTRUCTION CODE) CREATED BY JOHN GEORGE KENNY AND
o One of the first high-level languages ever developed for an THOMAS EUGENE KURTZ (SRC)
electronic computer. Short code statements are represented by o Designed for simplicity.
mathematical expressions. o Computer games were often written in Basic. (Microsoft’s Altair,
• 1952 (MANCHESTER MARK 1 DEVELOPED BY ALICK GLENNIE) Apple II)
o Considered as first compiled high – level programming language. • 1970 (PASCAL (BLAISE PASCAL) CREATED BY NIKLAUS WIRTH)
o Automatically convert language into a machine code. o For teaching structured programming and data structuring.
Commonly used for Windows Application development.
• 1957 (FORTRAN CREATED BY JOHN BACKUS)
o For numeric and scientific computing (as an alternative to • 1972 (C CREATED BY DENNIS RITCHIE OF BELL LABS)
assembly language). o o Currently the world’s most popular programming language.2
o Oldest programming language used today. Many leading languages are derivatives, including C#, Java,
JavaScript, Perl, PHP, and Python. System programming,
computer game development.

Programming Logic and Design By: Froilan G. Cantillo 10


BRIEF HISTORY OF PROGRAMMING LANGUAGE

• 1980 (ADA (AFTER ADA LOVELACE, CREATED BY JEAN ICHBIAH) • 1991 PYTHON (FOR BRITISH COMEDY TROUPE MONTY PYTHON)
o Derived from Pascal. CREATOR: GUIDO VAN ROSSUM OF CWI
o For developing large software systems. o Created to support a variety of Programming styles and be fun to
use.
o Primary Uses: Dept. of Defense, banking, manufacturing,
transportation, commercial aviation o Primary Uses: Web application, software development,
information security
• 1983 (C++ (FORMERLY “C WITH CLASSES”) CREATOR BJARNE o (Google, Yahoo, Spotify)
STROUSTRUP)
o An extension of C, with enhancements such as classes, virtual • 1993 RUBY (THE BIRTHSTONE OF ONE OF THE CREATOR’S
functions, and templates. COLLABORATOR) CREATOR: YUKIHIRO MATSUMOTO
o Primary Uses: Commercial application development, embedded o Designed for productive and enjoyable programming. (Twitter,
software, server/client applications, video games Hulu, Groupon) Primary Uses: Web application development
o Used by: Adobe, Google Chrome, Mozilla Firefox, Microsoft • 1994 (JAVA CREATOR: JAMES GOSLING OF MICROSYSTEMS)
Internet Explorer o Made for an interactive TV project. Cross-platform functionality.
• 1983 OBJECTIVE-C (OBJECT-ORIENTED EXTENSION OF “C”) Second most popular language (behind C).(Android OS/apps)
CREATOR: BRAD COX AND TOM LOVE OF STEPSTONE o Primary Uses: Network programming, web application
o Expanded on C, adding message-passing functionality based on development, software development, Graphical User Interface
Smalltalk language. development
o Used by: Apple’s OS X and iOS operating systems • 1994 (JAVA CREATOR: JAMES GOSLING OF MICROSYSTEMS)

Programming Logic and Design By: Froilan G. Cantillo 11


BRIEF HISTORY OF PROGRAMMING LANGUAGE

• 1995 (PHP (“PERSONAL HOME PAGE”) CREATOR: RASMUS


LERDORF)
o For building dynamic web pages. Most widely used open-source
software by enterprises.
o Primary Uses: Building/maintaining dynamic web pages, server-
side development
o Used by: Facebook, Wikipedia, Digg, WordPress, Joomla
• 1995 (PHP (“PERSONAL HOME PAGE”) CREATOR: RASMUS
LERDORF)
• 1996 (JAVASCRIPT (FINAL CHOICE AFTER “MOCHA” AND
“LIVESCRIPT” CREATOR: BRENDAN EICH OF NETSCAPE)
o Created to extend web page functionality.
o Dynamic web pages’ use for form submission/validation,
interactivity, animations, user activity tracking, etc.
o Primary Uses: Dynamic web development, PDF documents, web
browsers, desktop widgets
o Used By: Gmail, Adobe Photoshop, Mozilla Firefox
• 1996 (JAVASCRIPT (FINAL CHOICE AFTER “MOCHA” AND
“LIVESCRIPT” CREATOR: BRENDAN EICH OF NETSCAPE)

Programming Logic and Design By: Froilan G. Cantillo 12


HIERARCHY OF HIGH LEVEL LANGUAGES

High Level Languages


• High level languages are problem-orientated whereas low level
languages are machine-orientated.
• Problem-orientated means that the commands and the way the program
is structured are based on what the program will have to do rather than
the components of the computer it will be used with.
• This means that programs of high level languages are portable. These
High Level
Programming programs can be written on one computer and then executed on
Languages another.
• There are many types of high level languages, each is written to cope
with the demands of specific types of problems. E.g. some are designed
Imperative Declarative for scientific applications, manipulating databases, creating web pages
etc.
• There are 2 classified groups of high level languages
Object Database
o Imperative
Procedural Logic Functional
Oriented Query o Declarative

Programming Logic and Design By: Froilan G. Cantillo 13


ALGORITHM

What is an algorithm? Characteristics of an Algorithm


• A set of steps to accomplish a task • Unambiguous − Algorithm should be clear and unambiguous. Each of
its steps (or phases), and their inputs/outputs should be clear and must
• An algorithm is a sequence of unambiguous instruction lead to only one meaning.
• An algorithm is a well-defined procedure that allows a computer to • Input − An algorithm should have 0 or more well-defined inputs.
solved a problem.
• Output − An algorithm should have 1 or more well-defined outputs, and
• An algorithm is a self-contained step-by-step set of operation to be should match the desired output.
performed to solve a specific problem.
• Finiteness − Algorithms must terminate after a finite number of steps.
• Feasibility − Should be feasible with the available resources.
How to write an algorithm?
• Independent − An algorithm should have step-by-step directions, which
• Keep in mind that algorithm is a step-by-step process. should be independent of any programming code.
• Depending upon programming language, include syntax where
necessary.
Two forms of Algorithm:
• Include variables and their usage.
• Pseudocode
• If they are any loops, try to give sub number lists.
• Flowchart
• Try to give go back to step number if loop or condition fails.
• Use jump statement to jump from one statement to another.
• Try to avoid unwanted raw data in algorithm.
• Use break and stop to terminate the process.

Programming Logic and Design By: Froilan G. Cantillo 14


ALGORITHM: PSEUDOCODE

Pseudocode • Keywords are written in CAPITALS.


Pseudocode essentially is English with some defined rules of structure and • Structural elements come in pairs,
some keywords that make it appear a bit like program code. Some
guidelines for writing pseudocode are as follows. o for every BEGIN there is an END
o for every IF there is an ENDIF. etc.

Pseudocode Guidelines • Indenting is used to show structure in the algorithm.

• The keywords used for pseudocode in this document are: • The names of subprograms are underlined.
1. for start and finish o This means that when refining the solution to a problem. a word
BEGIN MAINPROGRAM, END MAINPROGRAM in an algorithm can be underlined and a subprogram developed.
2. for initialization This feature enables the use of the 'top-down' development concept.
INITIALISATION, END INITIALISATION where details for a particular process need only be considered within the
3. for subprogram relevant sub-routine.
BEGIN SUBPROGRAM. END SUBPROGRAM
4. for selection
IF. THEN, ELSE, ENDIF
5. for multi-way selection
CASEWHERE. OTHERWISE. ENDCASE
6. for pre-test repetition
WHILE. ENDWHILE
7. for post-test repetition
REPEAT. UNTIL

Programming Logic and Design By: Froilan G. Cantillo 15


ALGORITHM: FLOW CHARTS

Flow Charts Basic flowcharting shapes and symbols


• A drawing that uses symbols interconnected with lines to represent the Flowcharts use special shapes to represent different types of actions or
flow of information steps in a process and Lines and arrows show the sequence of the steps,
and the relationships among them.
• A process flow diagram that illustrates the successive steps in a
process, procedure, system or model.
• A pictorial representation showing/describing all of the steps of a Start/End – The terminator symbol marks the starting or ending point the
process being studied or even used to plan stages of a project. Flow system. It usually contains the word "Start" or "End."
charts tend to provide people with a common language or reference
point when dealing with a project or process.

Purpose of Flow Charts Action or Process – A box can represent a single step ("add two cups of
flour), or and entire sub-process ("make bread") within a larger process.
A Flowchart is used for:
1. Defining and analyzing processes
2. Building a step-by-step picture of the process for analysis, discussion,
or communication purposes Decision – A decision or branching point. Lines representing different
decisions emerge from different points of the diamond.
3. Defining, standardizing, or finding areas for improvement in a process
By visualizing the process, a flowchart can quickly help identify bottlenecks
or inefficiencies where the process can be streamlined or improved.

Programming Logic and Design By: Froilan G. Cantillo 16


ALGORITHM: FLOW CHARTS

Connector – Indicates that the flow continues where a matching symbol Example of Flowchart
containing the same letter) has been placed.

Flow Line – Lines indicate the sequence of steps and the direction of flow.

Input/ Output – Represents material or information entering or leaving the


system, such as customer order (input) or a product

Programming Logic and Design By: Froilan G. Cantillo 17


ALGORITHM: FLOW CHARTS

Common Types of Flowcharts 3. The Swimlane Flowchart


There are four flowchart types that are particularly versatile. These four Describe How Separate Departments, Processes or Employees
common diagrams are great for describing business, manufacturing, or Interact
administrative processes, seeing how an organization functions, or how
different departments work together. The swimlane flowchart comes in handy when you need to show
1. The Process Flowchart multiple flows of information side by side. Swimlane diagrams might
sound really similar to a workflow diagram, but the key here is that it
Illustrate How a Process Works or Plan a Project with a Process allows you to create different categories where activity takes place.
Flowchart
A process flowchart or process flow diagram is probably the most A swimlane flowchart or diagram is great for documenting a whole
versatile of the four commonly used flowchart types because it can be process that interacts with different segments of an organization or
applied to virtually anything. requires collaboration among different teams.
• Map out roles and responsibilities within an organization to gain 4. The Data Flowchart
clarity.
• Draw up a proposal for a new process or project to understand its See Where Data Flows In and Out of an Information System with a
scope and steps. Data Flow Diagram

2. The Workflow Chart A data flowchart or data flow diagram shows the way data is
processed. It comes in handy when you want to design or analyze a
Understand How Data and Documents Flow Within Your Organization system. Although most often used for software development and
design, it can be used to analyze any type of information flow, like how
A workflow chart shows the way a business or process functions. This information moves through a business.
type of workflow diagram can be used to:
• Train new employees
• Discover potential problem areas
• Clarify business operations by showing a high-level overview

Programming Logic and Design By: Froilan G. Cantillo 18


ALGORITHM: FLOW CHARTS

Steps for creating a flowchart are: CONSTRUCTION/INTERPRETATION tip for a flow chart.
1. Familiarize the participants with the flowchart symbols • Define the boundaries of the process clearly.
2. Brainstorm major process tasks. Ask questions such as "What really • Use the simplest symbols possible.
happens next in the process? ", "Does a decision need to be made
before the next step? ", or What approvals are required before moving • Make sure every feedback loop has an escape.
on to the next task?"
• There is usually only one output arrow out of a process box. Otherwise,
3. 3Draw the process flowchart using the symbols on a flip chart or it may require a decision diamond.
overhead transparency. Every process will have a start and an end
(shown by elongated circles). All processes will have tasks and most • Analyze flow chart of actual process.
will have decision points (shown by a diamond). • Analyze flow chart of best process.
4. Analyze the flowchart for such items as: • Compare both charts, looking for areas where they are different. Most of
• Time-per-event (reducing cycle time) 0 Process repeats (preventing the time, the stages where differences occur is considered to be the
rework) problem area or process.
• Duplication of effort (identifying and eliminating duplicated tasks) • Take appropriate in-house steps to correct the differences between the
• Unnecessary tasks (eliminating tasks that are in the process for no two separate flows.
apparent reason)
• Value-added versus non-value-added tasks

Programming Logic and Design By: Froilan G. Cantillo 19


ALGORITHM: FLOW CHARTS

Tips for Effective Flowcharts Flowchart and Pseudocode


1. Label each flowchart with a title identifying the process that it
illustrates. (For example: Entry Process").
2. Clearly indicate the starting and ending points of the process, using the
standard terminator symbols.
3. Keep the direction of flow consistent. Avoid confusion by keeping your
flow lines moving from top to bottom and left to right. Don't reverse the
direction in the chart unless the flow reverses itself in reality.
4. Break the steps down to a consistent level of detail. Don't include trivial
sub-steps of one task while treating another equivalent task as a
whole. If one step or task needs to be analyzed in detail, make a
separate chart illustrating that sub-process.
• You can hyperlink the shape representing a sub-process that,
illustrates it, allowing users to "drill down" for more detail.)
5. Avoid crossing flow lines. In a well-designed chart, flow lines will not
cross each other. By rearranging a chart, you can usually get rid of
crossed lines. If two lines must cross, use a "bridge" (also known as a
"line hop") to show that the lines do not intersect.
6. Make sure there are at least two no outcomes from every decision
diamond.
7. Label your flowchart components. Use active verbs to label activity
steps and questions to label decisions. Clearly label the form a
decision diamond in terms that answer the question.

Programming Logic and Design By: Froilan G. Cantillo 20


DATA TYPES

Data Types We can declare it as below.


• A data type defines a set of values and a set of operation on those Char a= ‘A’
values. A C++ program may need to required different type of data. Char f= ‘B’
Each type required different type of memory. Char z= ‘D’ etc
• It indicates the type of data that can be store in a variable
• There are three basic data type. Integer data type:
o Character • A numeric value with no fraction is called integer data. It include both
o Integer positive and negative values.
o Float • Represented by “int”
• Int range –32,768 to 32,767
Character data type • Some example of integer value are 56 and -12
• This data type is used to store character values. • Int size is ‘2’ bytes
• Characters may include letters, digits and punctuation character. It take • Long int size ‘4’ bytes
one byte in memory i.e. ‘a’ and ‘@’ etc.
• Represented by the “char” data type.
We can declare it as below.
• The “short” data type is the same size as “char” usually one byte.
Int a=20;
• The character variable can store only one character Int b=40;
• The Character range is “-128 to 127” Int c=30;

Programming Logic and Design By: Froilan G. Cantillo 21


DATA TYPES

Type of Integer data type Type of float


Int data type • Float data type
• To store integer values and takes two byte in memory. i.e. int num; o This data type is used to store real values and
o Takes ‘4’ bytes in memory. i.e. Float num;
Long int data type
• Double data type
• To store large integer value. It has greater range and takes ‘4’ bytes in
memory. i.e. long int num; o It has great range as compared to float and takes ‘8’ byte in
memory. i.e. Double num;

Float data type:


• A numeric value with fraction is called real data type / float data type. It
include both
• Positive and negative values. i.e. 12.4 and -34.3
• This data type are represented by “float”.
• Float number are declared as
Float a= “40.00”
Float b= “23.04”
Float c= “10.3” etc.

Programming Logic and Design By: Froilan G. Cantillo 22


DATA TYPES

Variable Rules for variable Declaration


• A quantity whose values may change during the execution of the • Variable may include letter, number and underscore (_)
program is called variable.
• The first latter of the variable must be character or underscore.
• It may be a numeric or non-numeric quantity
• Blank spaces special symbols, commas are not used
• It represented by an identifier called variable name
• A variable can be ‘31’ character long for many compilers
• A variable represents a memory location in the computer memory. Data
is store into the memory location. The name of memory location or • Key word are not used as variable name.
variable name remains fixed during the execution of the program but the
Variable Declaration
data store in that location may change from time to time
• The process of specifying the name and its data type is called variable
declaration
Variable Declaration
• All variables that are used in a program are declared using variable
• A variable is case sensitive, that is, uppercase variables are treated declaration statement.
differently
• When a variable is declared a certain number of bytes in the memory
• Variable “SUM” is different from variable “sum” are allocated to the variable name.

• Variable “NetPay” is different from variable “NETpay” Variable Initialization


• The process of assigning a value to a variable at the time of declaration
is known as variable initialization.
• The equal (=) is used to initialize a variable.
• Variable name is given on the left side and value is given on the right
side of equal sign.

Programming Logic and Design By: Froilan G. Cantillo 23


ARDUINO

Introduction • The Arduino software is easy-to-use for beginners, yet flexible enough
for advanced users.
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 • It runs on Mac, Windows, and Linux. Teachers and students use it to
sensor, a finger on a button, or a Twitter message - and turn it into an build low-cost scientific instruments or to get started with programming
and robotics.
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 • Arduino is a key tool to learn new things.
to the microcontroller on the board.
• Anyone can start tinkering just following the step-by-step instructions of
a kit, or sharing ideas online with other members of the Arduino
community.
arduino.cc

What is Arduino?
Inexpensive – Arduino boards are relatively inexpensive compared to
• Arduino is an open-source electronics platform based on easy-to-use other microcontroller platforms.
hardware and software. Cross-platform – The Arduino Software (IDE) runs on Windows,
• Arduino boards are able to read inputs and turn it into an output. Macintosh OSX, and Linux operating systems. Most microcontroller
systems are limited to Windows.
• You can tell your board what to do by sending a set of instructions to the Simple, clear programming environment – The Arduino Software (IDE)
microcontroller on the board. is easy-to-use for beginners, yet flexible enough for advanced users to
take advantage of as well.
• Arduino was born at the Ivrea Interaction Design Institute
Open source and extensible software – The Arduino software is
• Easy tool for fast prototyping published as open source tools, available for extension by experienced
programmers.
• Aimed at students without a background in electronics and
programming. Open source and extensible hardware – The plans of the Arduino
boards are published under a Creative Commons license, so experienced
Why Arduino? circuit designers can make their own version of the module, extending it
and improving it.
• Arduino has been used in thousands of different projects and
applications.

Programming Logic and Design By: Froilan G. Cantillo 24


TYPES OF ARDUINO
arduino.cc

Programming Logic and Design By: Froilan G. Cantillo 25


TYPES OF ARDUINO: UNO

Arduino Uno
Processor: ATmega328 (8-bit CPU, 16MHz clock speed, 2KB SRAM,
32KB flash storage)
Features: 14 digital I/O pins, 6 analog input pins, removable
microcontroller
Form Factor: 2.7” x 2.1” rectangle
arduino.cc

The Arduino Uno is the most “standard” Arduino board currently on the
market, and is probably the best choice for beginners just getting started
with the platform. The board is compatible with more shields (add-on
boards) than other models.
The Uno’s main limitation is the ATmega328 chip, which doesn’t have a lot
of SRAM or flash memory. That limit’s the kinds of programs you can load
on the chip – if your project involves a display or otherwise needs to store
and use any form of images or audio data, 2KB of memory probably isn’t
going to be enough.

Programming Logic and Design By: Froilan G. Cantillo 26


TYPES OF ARDUINO : MEGA

Arduino Mega
Processor: ATmega2560 (8-bit CPU, 16MHz clock speed, 8KB SRAM,
256KB flash storage)
Features: 54 digital I/O pins (15 PWM), 16 analog input pins, 4 UARTs, 16
MHz crystal oscillator
Form Factor: 101.52mm x 53.3mm rectangle
arduino.cc

The Mega is a microcontroller board based on the ATmega2560. The


Mega is compatible with most shields designed for the Arduino
Duemilanove or Diecimila. It is intended for comparatively bigger projects
requiring a large number of input and output pins.

Programming Logic and Design By: Froilan G. Cantillo 27


TYPES OF ARDUINO : NANO

Arduino Nano
Processor: ATmega328 (8-bit CPU, 16MHz clock speed, 2KB SRAM,
32KB flash storage)
Features: 22 digital I/O pins, 8 analog input pins
Form Factor: 18mm x 45mm rectangle
arduino.cc

The Arduino Nano is a small, complete, and breadboard-friendly board


based on the ATmega.328 (Arduino Nano 3.x). It has more or less the
same functionality of the Arduino Duemilanove, but in a different package.
It lacks only a DC power jack, and works with a mini-B USB cable instead
of a standard one.

Programming Logic and Design By: Froilan G. Cantillo 28


TYPES OF ARDUINO: MINI

Arduino Mini
Processor: ATmega328 (8-bit CPU, 16MHz clock speed, 2KB SRAM,
32KB flash storage)
Features: 14 digital I/O pins, 8 analog input pins, 16 MHz crystal oscillator
Form Factor: 30mm x 18mm rectangle
arduino.cc

The Arduino Mini is a small microcontroller board originally based on the


ATmega168, but now supplied with the 328 (datasheet), intended for use
on breadboards and when space is at a premium.
The new Mini (revision 05) has a new package for the ATmega, which
enable all components to be on the top of the board. It also has an
onboard reset button.

Programming Logic and Design By: Froilan G. Cantillo 29


TYPES OF ARDUINO: LEONARDO

Arduino Leonardo
Processor: ATmega32u4 (8-bit CPU, 16MHz clock speed, 2KB SRAM,
32KB flash storage)
Features: 20 digital I/O pins (7 PWM), 12 of which can be used as analog
inputs, native USB support
Form Factor: 68.6mm x 53.3mm rectangle
arduino.cc

The Leonardo is, essentially, a slight upgrade to the Uno. It looks a lot like
the Uno, but it features a soldered-on ATmega32u4 microcontroller with a
tiny bit more memory. The main advantage of the ATmega32u4 isn’t the
extra SRAM, though, it’s the chip’s built-in USB compatibility. This allows
the Leonardo to interface with a PC, which sees it as a generic mouse or
keyboard. It also features a few extra analog input pins.

Programming Logic and Design By: Froilan G. Cantillo 30


TYPES OF ARDUINO: DUE

Arduino Due
Processor: Atmel SAM3X8E ARM Cortex-M3 (32-bit CPU, 84MHz clock
speed, 96KB SRAM, 512KB flash storage)
Features: 54 digital I/O pins (12 PWM), 12 analog input pins, 2 analog
output pins, native USB port
Form Factor: 101.52mm x 53.3mm rectangle
arduino.cc

One of the newest Arduino boards, the Due is the heavy-hitter of the
family, packing a 32-bit ARM processor that handily outclasses any of the
processors found in other Arduino boards. The Due is primarily for more
complicated projects that can make sure of its muscular processor, or that
need more I/O pins than are found on the smaller Arduino boards. That
said, the Due is substantially bigger and more expensive than the Uno or
Leonardo, so consider whether you really need the extra power before
making a purchase.
One drawback to the Due is that it operates at 3.3 volts, which is different
than the 5 volts that most other Arduino boards operate at. That limits the
add-on hardware that’s compatible with the Arduino Due – if an add-on
board tries to send a 5 volt signal to the Due’s I/O pins, it could damage
the microcontroller.

Programming Logic and Design By: Froilan G. Cantillo 31


TYPES OF ARDUINO LILYPAD

Arduino Lilypad
Processor: ATmega328 (8-bit CPU, 16MHz clock speed, 2KB SRAM,
32KB flash storage)
Features: 14 digital I/O pins, 6 analog input pins
Form Factor: 2” diameter circle
arduino.cc

The Lilypad is an Arduino board specifically designed for wearable


devices. Its circular shape and standoff-less I/O pins are designed to make
it easy to sew the Lilypad into fabric-based projects.
The hardware on a standard LilyPad board is basically the same as on
and Arduino Uno. There are a number of other LilyPad options available
as well, including the LilyPad Arduino USB, which feature’s the Leonardo’s
ATmega32u4 chip, the Lilypad Arduino Simple, which has fewer I/O
connections than the basic model, and the LilyPad Arduino SimpleSnap,
which can be snapped into and out of projects, so they can be safely
washed.

Programming Logic and Design By: Froilan G. Cantillo 32


PARTS OF ARDUINO UNO

1 – Power USB
Arduino board can be powered by using the USB cable from your
computer. All you need to do is connect the USB cable to the USB
connection (1).
2 – Power (Barrel Jack)
Arduino boards can be powered directly from the AC mains power supply
by connecting it to the Barrel Jack (2).
arduino.cc

3 – Voltage Regulator
The function of the voltage regulator is to control the voltage given to the
Arduino board and stabilize the DC voltages used by the processor and
other elements.
4 – Crystal Oscillator
The crystal oscillator helps Arduino in dealing with time issues. How does
Arduino calculate time? The answer is, by using the crystal oscillator. The
number printed on top of the Arduino crystal is 16.000H9H. It tells us that
the frequency is 16,000,000 Hertz or 16 MHz.
5,17 – Arduino Reset
You can reset your Arduino board, i.e., start your program from the
beginning. You can reset the UNO board in two ways. First, by using the
reset button (17) on the board. Second, you can connect an external reset
button to the Arduino pin labelled RESET (5).

Programming Logic and Design By: Froilan G. Cantillo 33


PARTS OF ARDUINO UNO

6,7,8,9 – Pins (3.3, 5, GND, Vin)


• 3.3V (6) − Supply 3.3 output volt
• 5V (7) − Supply 5 output volt
• Most of the components used with Arduino board works fine with 3.3
volt and 5 volt.
• GND (8)(Ground) − There are several GND pins on the Arduino, any of
which can be used to ground your circuit.
arduino.cc

• Vin (9) − This pin also can be used to power the Arduino board from an
external power source, like AC mains power supply.
10 – Analog pins
The Arduino UNO board has six analog input pins A0 through A5. These
pins can read the signal from an analog sensor like the humidity sensor or
temperature sensor and convert it into a digital value that can be read by
the microprocessor.
11 – Main Microcontroller
Each Arduino board has its own microcontroller (11). You can assume it as
the brain of your board. The main IC (integrated circuit) on the Arduino is
slightly different from board to board. The microcontrollers are usually of
the ATMEL Company. You must know what IC your board has before
loading up a new program from the Arduino IDE. This information is
available on the top of the IC. For more details about the IC construction
and functions, you can refer to the data sheet.

Programming Logic and Design By: Froilan G. Cantillo 34


PARTS OF ARDUINO UNO

12 – ICSP pin
Mostly, ICSP (12) is an AVR, a tiny programming header for the Arduino
consisting of MOSI, MISO, SCK, RESET, VCC, and GND. It is often
referred to as an SPI (Serial Peripheral Interface), which could be
considered as an "expansion" of the output. Actually, you are slaving the
output device to the master of the SPI bus.
13 – Power LED indicator
This LED should light up when you plug your Arduino into a power source
arduino.cc

to indicate that your board is powered up correctly. If this light does not
turn on, then there is something wrong with the connection.
14 – TX and RX LEDs
On your board, you will find two labels: TX (transmit) and RX (receive).
They appear in two places on the Arduino UNO board. First, at the digital
pins 0 and 1, to indicate the pins responsible for serial communication.
Second, the TX and RX led (13). The TX led flashes with different speed
while sending the serial data. The speed of flashing depends on the baud
rate used by the board. RX flashes during the receiving process.

Programming Logic and Design By: Froilan G. Cantillo 35


PARTS OF ARDUINO UNO

15 – Digital I/O
The Arduino UNO board has 14 digital I/O pins (15) (of which 6 provide
PWM (Pulse Width Modulation) output. These pins can be configured to
work as input digital pins to read logic values (0 or 1) or as digital output
pins to drive different modules like LEDs, relays, etc. The pins labeled “~”
can be used to generate PWM.
16 – AREF
AREF stands for Analog Reference. It is sometimes, used to set an
arduino.cc

external reference voltage (between 0 and 5 Volts) as the upper limit for
the analog input pins.

Programming Logic and Design By: Froilan G. Cantillo 36


ARDUINO IDE

Arduino Software Connect your Arduino Uno to your PC via USB Cable
You can download the Arduino IDE (The program used to write code and Select your board
uploading it to Arduino boards) from https://www.arduino.cc/en/software
• Tools → Board: “Arduino/Ginuino Uno” → Arduino/Ginuino Uno
Select your serial port
Name of Sketch
• Tools → Port

Verify: Compile Sketch


arduino.cc

Upload: Upload the


program to the board Compile:
Serial Monitor • Compile the sketch after writing the code
• Check your codes for error

Code Area New Open Save Upload:


• Upload the program to the configured Arduino board

Messages / Error

Programming Logic and Design By: Froilan G. Cantillo 37


STRUCTURE: SKETCH

The basic code structure of Arduino programming is simple and is


composed of two parts:
1. Setup
2. Loop

The code you write for your Arduino are known as sketches. They are
written in C++.
arduino.cc

Every sketch needs two void type functions, setup() and loop(). A void type
function doesn’t return any value.

The setup() method is ran once, just after the Arduino is powered up, and
the loop() method is ran continuously afterwards.
The setup() is where you want to do any initialization steps, and in loop()
you want to run the code you want to run over and over again.

Programming Logic and Design By: Froilan G. Cantillo 38


STRUCTURE: CONTROL STRUCTURE

if Statement If…else
‘if’ statements test whether a certain condition has been reached, such as The ‘if…else’ statements allow either/or statements to be made. These
whether a number has reaches a certain value, and if true, executes the statements can be used when more than one courses of action are
statements in the brackets. The code in the brackets is skipped if the possible, as determined by the variable or value being tested. The syntax
statement is false. for ‘if…else’ implementation is:
The syntax for if statement is:
void loop(){

void loop(){
arduino.cc

if(inputPin == HIGH){
doThing1;
if(somevariable <testcondition> value){
}else{
doSomething;
doThing2;
}
}

}
}

The above condition test compares somevariable with a value. If this


condition is satisfied, then the code inside the parenthesis (dosomething)
is executed.

Programming Logic and Design By: Froilan G. Cantillo 39


STRUCTURE: CONTROL STRUCTURE

If…else if ladder for Statement


If more than two courses of action are possible, then the ‘if…else if’ ladder The ‘for’ statement is used to repeat a statement of a block of statements
is to be used, which allows the choice and execution of one statement a specified number of times. The arguments for the ‘for’ loop consists of:
from an infinite number of possibilities. The syntax is as follows:
1. Initialization. This initializes a variable with a specified initial value.
2. Test condition. This condition is tested for every loop and the ‘for’
void loop(){
statement stops looping when this condition does not hold true.

if(inputPin <testcondition> value1){ 3. Increment/decrement expression. This expression operates on the


arduino.cc

initialized variable.
doThing1;
}else if(inputPin <testcondition> value2){ The syntax for the ‘for’ loop is as follows:
doThing2;
}else if(inputPin <testcondition> value3){ void loop(){
doThing3;
}else{ for(initialization; condition; increment/decrement
doThing4; expression){
} doSomething;
}
}
}

Programming Logic and Design By: Froilan G. Cantillo 40


STRUCTURE: CONTROL STRUCTURE

while Loop do…while Loop


The ‘while’ loop will loop continuously and infinitely, until the expression The ‘do…while’ class works in a similar manner to the ‘while’ class, the
inside the brackets become false. If the tested variable of value is not only difference being, that, in the ‘do…while’ class the condition is tested
changed, the loop will go on for infinity. at the bottom of the loop, making sure the loops is carried out at least
once.

void loop(){
void loop(){
while(variable <test condition> value){
arduino.cc

doSomething; do{
} doSomething;
}while(variable <test condition> value)
}
}

Programming Logic and Design By: Froilan G. Cantillo 41


CONSTANT: HIGH/LOW

HIGH/LOW
These are constraints used to signify 0V or 5V (logic 0 or 1) when writing
or reading from digital pins. In the following example, if the pin value on pin
11 is HIGH, the pin value on pin 12 is set as HIGH.

void setup(){
pinMode(12, OUTPUT);
pinMode(11, INPUT);
arduino.cc

void loop(){

if(digitalRead(11) == HIGH){
digitalWrite(12, HIGH);
}

Programming Logic and Design By: Froilan G. Cantillo 42


FUNCTIONS: DIGITAL INPUT/OUTPUT

pinMode For convenience there are 20k ohm pull up resistors built into the ATmega
chip which can be accessed through software in the following manner:
This command is used to set pins as input or output in the Setup().
Arduino digital pins are set to input by default, hence there is no need to
specifically declare them as inputs using pinMode(). Pins configured as void setup(){
inputs are said to be in a high impedance state.
pinMode(11, INPUT); //Sets pin 11 as input
The syntax for declaring pins using pinMode() is as follows: digitalWrite(11, HIGH); //Turns on 20k-ohms
//pullup resistor
}
void setup(){
arduino.cc

pinMode(11, INPUT); //Sets pin 11 as input void loop(){


pinMode(12, OUTPUT); //Sets pin 12 as output
} }

void loop(){
Pins set as OUTPUT are said to be in a low resistance state and can
} supply 40mA of current to connected circuits or components.

Programming Logic and Design By: Froilan G. Cantillo 43


FUNCTIONS: DIGITAL INPUT/OUTPUT

digitalRead digitalWrite
This function is used to read the digital value of a pin. The result is either Sets the pins on or off, by giving them either HIGH or LOW output. The
HIGH or LOW. function takes two parameters, the pin number and either HIGH or LOW,
as follows:
The syntax is as follows:

void setup(){
void setup(){
pinMode(12, OUTPUT); //Sets pin 12 as output
pinMode(11, INPUT); //Sets pin 11 as input
}
arduino.cc

void loop(){
void loop(){
digitalWrite(12, HIGH); //Sets value of pin 12 as HIGH
int value = digitalRead(11); //Sets variable value
//equal to the input pin
} }

Programming Logic and Design By: Froilan G. Cantillo 44


FUNCTIONS: ANALOG INPUT/OUTPUT

analogRead analogWrite
This function reads the value from a specified analogue pin and returns a This function is used to give an analog output. Analog outputs can only be
value between 0-1023. It only works on the six analogue pins from 0-5. given to pins 3, 5, 6, 9, 10 and 11 on the Uno. Values between 0-255 can
be given to the analog pins.
The syntax is as follows:
The syntax is as follows:

void setup(){
pinMode(0, INPUT); //Sets pin 0 as input void setup(){
arduino.cc

} pinMode(3, OUTPUT); //Sets pin 3 as output


}
void loop(){
int value = analogRead(0); //Reads the analogue value void loop(){
//between 0-1023) of the analogWrite(3, value); //Sets the value of analog pin
//analog pin 0 //3 equal to value (must be
} //from 0-255)
}

Programming Logic and Design By: Froilan G. Cantillo 45


FUNCTIONS: TIME

millis() micros()
Acts like a clock and returns the number of milliseconds that have passed Similar to millis(), it acts like a clock and returns the number of
since the Arduino board began running the current program as an microseconds that have passed since Arduino board began running the
unsigned long int. The clock resets to zero after about 9 hours: current program as an unsigned long int. This number will overflow and
become zero again after approximately 70 minutes:

void loop(){ Pins set as OUTPUT are said to be in a low resistance state and can
supply 40mA of current to connected circuits or components.
int timeelapsed = millis(); //Sets the variable
//timelapsed to the number
arduino.cc

//of milliseconds passed


//since program execution unsigned long time;
}
void setup()(
Serial.begin(9600);
}

void loop()
Serial.print(“Time: ");
time = micros(); //prints time since program started
Serial.println(time); //wait a second so as not to
//send massive amount of data
delay(1000);

Programming Logic and Design By: Froilan G. Cantillo 46


FUNCTIONS: TIME

delay(ms) delayMicroseconds(us)
Pauses the program for the specified amount of time. The arguments take Here, ‘us’ is the time in microseconds. Similar to delay(ms), this function
time duration in milliseconds: pauses the program for the specified amount of time. The arguments take
time duration in microseconds as an unsigned int:

void loop()(
int outPin = 8; //digital pin 8
digitalWrite(11, HIGH);
arduino.cc

delay(1000); //Pauses the program for 1000 void setup(){


//millisecond or 1 second
pinMode(outPin, OUTPUT); //Sets the digital pin as
} //output
}

void loop(){

digitalWrite(outPin, HIGH); //Sets the pin on


delayMicroseconds(100); //Pauses for 100
//microseconds
digitalWrite(outPin, LOW); //Sets the pin off
delayMicroseconds(100); //Pauses for 100
//microseconds
}

Programming Logic and Design By: Froilan G. Cantillo 47


FUNCTIONS: MATH

min(x,y) max(x,y)
Returns the smaller of the two values passed into the function as Returns the larger of the two values passed into the function as
arguments. arguments.

void loop(){ void loop(){

int x,y; int x,y;


arduino.cc

int smaller_num = min(x,y); //Sets smaller_num equal int larger_num = max(x,y); //Sets larger_num equal to
//to x or y depending upon //x or y depending upon
//whichever is smaller //whichever is larger
} }

Programming Logic and Design By: Froilan G. Cantillo 48


FUNCTIONS: RANDOM NUMBERS

randomSeed(seed) random(min,max)
Sets a value as a starting point before the random() function. The seed This function helps in generating pseudo-random values for the given
can be any variable, input, constraints or other functions. Must be used range in the arguments. The function randomSeed(seed) must be used
before the random function. before using this function.

void loop(){

void loop(){
int value_1;
arduino.cc

randomSeed(analogRead(3)); //Uses the analog value at


//pin 3 to set a starting int value_2;
//point for the random
//function
} rendomSeed(analogRead(3));

value_l = random(100); //Sets value_l equal to any


//random number between 0 and
//100
value_2 = random(50,100): //Sets value_2 equal to any
//random number between SO
//and 100
}

Programming Logic and Design By: Froilan G. Cantillo 49


FUNCTIONS: COMMUNICATION

Serial.begin() Serial.println()
This function opens up the USB port for serial communication and also Prints the value passed into the brackets on to the Serial Monitor.
sets the baud rate. Typical baud rate for serial communication with
computer is 9600bps.
void loop(){
int value = 100;
void setup(){
Serial.begin(9600); //Opens the serial port and sets
//the band rate at 9600bps Serial.println(value); //Prints value on to the Serial
//Monitor followed by a return
arduino.cc

} //carry and line feed


}

Click the encircled link to bring up the Serial Monitor.

Programming Logic and Design By: Froilan G. Cantillo 50


REFERENCE

https://www.arduino.cc/
https://en.wikipedia.org/wiki/Arduino
https://www.slideshare.net/
arduino.cc

Programming Logic and Design By: Froilan G. Cantillo 51

You might also like