Arduinofinal 210524112613
Arduinofinal 210524112613
Logic
and
Design
By: Froilan G. Cantillo
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.
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
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.
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.
• 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.
• 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)
• 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
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.
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.
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
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
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.
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.
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
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
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
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.
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.
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
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).
• 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.
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.
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.
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
Messages / Error
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.
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;
}
}
}
}
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;
}
}
}
void loop(){
void loop(){
while(variable <test condition> value){
arduino.cc
doSomething; do{
} doSomething;
}while(variable <test condition> value)
}
}
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);
}
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
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.
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
} }
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
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
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);
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
void loop(){
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.
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
} }
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
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
https://www.arduino.cc/
https://en.wikipedia.org/wiki/Arduino
https://www.slideshare.net/
arduino.cc