100% found this document useful (1 vote)
24 views

Programming and Interfacing with Arduino 1st Edition Yogesh Misra - Quickly access the ebook and start reading today

The document provides information about various eBooks available for download, including titles related to Arduino programming and interfacing, machine component design, and social science. It features links to specific eBooks such as 'Programming and Interfacing with Arduino' by Yogesh Misra and others. Additionally, it outlines the structure and content of the Arduino book, including chapters on programming constructs, I/O devices, and interfacing techniques.

Uploaded by

aosakimeyrav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
24 views

Programming and Interfacing with Arduino 1st Edition Yogesh Misra - Quickly access the ebook and start reading today

The document provides information about various eBooks available for download, including titles related to Arduino programming and interfacing, machine component design, and social science. It features links to specific eBooks such as 'Programming and Interfacing with Arduino' by Yogesh Misra and others. Additionally, it outlines the structure and content of the Arduino book, including chapters on programming constructs, I/O devices, and interfacing techniques.

Uploaded by

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

Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.

com

Programming and Interfacing with Arduino 1st


Edition Yogesh Misra

https://ebookmeta.com/product/programming-and-interfacing-
with-arduino-1st-edition-yogesh-misra/

OR CLICK HERE

DOWLOAD EBOOK

Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Programming Arduino: Getting Started with Sketches, Third


Edition Simon Monk

https://ebookmeta.com/product/programming-arduino-getting-started-
with-sketches-third-edition-simon-monk/

ebookmeta.com

Arduino: A Beginner's Guide to Arduino Programming 1st


Edition George Gibson

https://ebookmeta.com/product/arduino-a-beginners-guide-to-arduino-
programming-1st-edition-george-gibson/

ebookmeta.com

Arduino Arduino User Guide for Operating system


Programming Projects and More 2nd Edition Robert Scott

https://ebookmeta.com/product/arduino-arduino-user-guide-for-
operating-system-programming-projects-and-more-2nd-edition-robert-
scott/
ebookmeta.com

Fundamentals of Machine Component Design 7th Edition


Robert C. Juvinall

https://ebookmeta.com/product/fundamentals-of-machine-component-
design-7th-edition-robert-c-juvinall/

ebookmeta.com
China s Belt and Road Vision Geoeconomics and Geopolitics
S Mahmud Ali

https://ebookmeta.com/product/china-s-belt-and-road-vision-
geoeconomics-and-geopolitics-s-mahmud-ali/

ebookmeta.com

Love Me Harder Welcome to Cupids Cove 1st Edition M K


Moore

https://ebookmeta.com/product/love-me-harder-welcome-to-cupids-
cove-1st-edition-m-k-moore/

ebookmeta.com

Rising Up Living On Re Existences Sowings and Decolonial


Cracks 1st Edition Catherine E. Walsh

https://ebookmeta.com/product/rising-up-living-on-re-existences-
sowings-and-decolonial-cracks-1st-edition-catherine-e-walsh/

ebookmeta.com

The Philosophy of Social Science New Perspectives 2nd


Edition Garry Potter

https://ebookmeta.com/product/the-philosophy-of-social-science-new-
perspectives-2nd-edition-garry-potter-2/

ebookmeta.com

She Speaks Her Anger Myths Conversations of Gimi Women A


Psychological Ethnography in the Eastern Highlands of
Papua New Guinea 1st Edition Gillian Gillison
https://ebookmeta.com/product/she-speaks-her-anger-myths-
conversations-of-gimi-women-a-psychological-ethnography-in-the-
eastern-highlands-of-papua-new-guinea-1st-edition-gillian-gillison/
ebookmeta.com
Mastering Java: A Beginner's Guide 1st Edition Sufyan Bin
Uzayr

https://ebookmeta.com/product/mastering-java-a-beginners-guide-1st-
edition-sufyan-bin-uzayr/

ebookmeta.com
Programming and
­Interfacing with Arduino
Programming and
­Interfacing with Arduino

Dr. Yogesh Misra


First edition published 2022
by CRC Press
6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487-2742

and by CRC Press


2 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN

© 2022 Yogesh Misra

CRC Press is an imprint of Taylor & Francis Group, LLC

Reasonable efforts have been made to publish reliable data and information, but the author and
­publisher cannot assume responsibility for the validity of all materials or the consequences of
their use. The authors and publishers have attempted to trace the copyright holders of all material
­reproduced in this publication and apologize to copyright holders if permission to publish in this
form has not been obtained. If any copyright material has not been acknowledged please write and
let us know so we may rectify in any future reprint.

Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced,
transmitted, or utilized in any form by any electronic, mechanical, or other means, now known
or hereafter invented, including photocopying, microfilming, and recording, or in any information
storage or retrieval system, without written permission from the publishers.

For permission to photocopy or use material electronically from this work, access www.copyright.
com or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA
01923, 978-750-8400. For works that are not available on CCC please contact m
­ pkbookspermissions@
tandf.co.uk

Trademark notice: Product or corporate names may be trademarks or registered trademarks and are
used only for identification and explanation without intent to infringe.

ISBN: 978-1-032-05985-3 (hbk)


ISBN: 978-1-032-06316-4 (pbk)
ISBN: 978-1-003-20170-0 (ebk)

Typeset in Times
by codeMantra
Contents
Preface.......................................................................................................................xi
Acknowledgments .................................................................................................. xiii
Author ...................................................................................................................... xv
Abbreviations Used in This Book ..........................................................................xvii

Chapter 1 Introduction to Arduino UNO Board ...................................................1


Learning Outcomes ..............................................................................1
1.1 Features of Arduino UNO Board ..............................................1
1.2 Arduino IDE Software ..............................................................3
1.2.1 Editor ............................................................................3
1.2.2 Compiler .......................................................................3
1.2.3 Linker ........................................................................... 3
1.2.4 Locator .........................................................................4
1.2.5 Hex Converter .............................................................. 4
1.2.6 Loader...........................................................................4
1.3 Arduino IDE Download ............................................................4
1.4 Working with Arduino IDE .......................................................5
1.5 Introduction to ATmega 328 ...................................................... 7
1.6 Serial Peripheral Interface (SPI) Communication Protocol ...... 9
1.6.1 Steps of SPI Data Transmission – The Steps for
Data Transmission in SPI Protocols are as Follows: .... 9
1.6.2 Advantages of SPI Data Transmission –
The Advantages of Data Transmission in
SPI Protocols are as Follows: ..................................... 11
1.6.3 Disadvantages of SPI Data Transmission –
The Disadvantages of Data Transmission in
SPI Protocols are as Follows: ..................................... 11
1.7 Inter-Integrated Circuit (I2C) Communication Protocol......... 11

Chapter 2 Arduino Programming Constructs ..................................................... 15


Learning Outcomes ............................................................................ 15
2.1 Structure of Arduino Programming ........................................ 15
2.1.1 Setup() .................................................................... 15
2.1.2 Loop() ...................................................................... 15
2.1.3 Variables ..................................................................... 15
2.1.4 Constant...................................................................... 16
2.1.5 Integer......................................................................... 16
2.2 Function ................................................................................... 16
2.2.1 pinMode(pin, mode)........................................... 16
2.2.2 digitalWrite(pin, value) ............................... 17

v
vi Contents

2.2.3 digitalRead(pin)................................................. 18
2.2.4 analogRead(pin) .................................................. 19
2.2.5 analogWrite(pin, value) ................................20
2.2.6 delay(value) .........................................................20
2.2.7 for loop ..................................................................... 21
2.2.8 Serial.begin(rate) ............................................ 21
2.2.9 Serial.print(“argument”) ............................... 21
2.2.10 Serial.println(“argument”) .......................... 21
2.2.11 if statement ............................................................... 22
2.2.11.1 Simple if.................................................... 22
2.2.11.2 if/else ..................................................... 23
2.2.11.3 Multiple if/else.......................................24
2.2.12 map function...............................................................25

Chapter 3 I/O Devices, Actuators, and Sensors .................................................. 27


Learning Outcomes ............................................................................ 27
3.1 Light-Emitting Diode (LED) ................................................... 27
3.1.1 LED under Forward Bias ........................................... 27
3.1.2 LED under Reverse Bias ............................................ 27
3.1.3 Interfacing of LED with Arduino UNO ..................... 29
3.2 Switch ...................................................................................... 29
3.3 Seven-Segment Display ........................................................... 31
3.3.1 Common Cathode Seven-Segment Display (CC)....... 31
3.3.2 Common Anode Seven-Segment Display (CA) .........34
3.4 LCD Module............................................................................ 35
3.5 Potentiometer ........................................................................... 37
3.5.1 Internal Schematic of Potentiometer .......................... 38
3.5.2 Working of Potentiometer .......................................... 38
3.6 Analog-to-Digital Converter (ADC) .......................................40
3.6.1 Pin Description of ADC 804 ......................................40
3.6.2 Analog to the Digital Data Conversion Process in
ADC 804 .................................................................... 42
3.6.3 Important Terminology of ADC ................................ 43
3.6.4 Analog Inputs in Arduino UNO Board ......................44
3.7 Pulse Width Modulation (PWM) ............................................44
3.7.1 Working of PWM Concept......................................... 45
3.7.2 Applications of PWM................................................. 45
3.7.3 PWM Pins in Arduino UNO Board ...........................46
3.8 Temperature Sensor LM35 ...................................................... 47
3.9 Humidity and Temperature Sensor DHT11 ............................. 48
3.9.1 Pin Description of DHT11.......................................... 48
3.9.2 General Features of DHT11 ....................................... 48
3.9.3 Working Principle of DHT11 ..................................... 49
3.9.4 Timing Diagram of DHT11 ........................................ 50
3.9.5 Data Format of DHT11............................................... 50
Contents vii

3.10 Motor Driver L293D................................................................ 51


3.10.1 Pin Description of L293D .......................................... 51
3.10.2 Working of L293D ..................................................... 52
3.10.3 Description of L293D Motor Driver Module ............. 57
3.11 Relay ........................................................................................ 58
3.11.1 Pin Description of the Relay ...................................... 58
3.11.2 Working of Relay ....................................................... 59
3.11.3 Interfacing of Relay .................................................... 59
3.11.4 Relay Board ................................................................ 62
3.12 Light-Dependent Resistor (LDR) ............................................ 62
3.12.1 Working Principle of LDR ......................................... 62
3.12.2 Construction of LDR .................................................. 63
3.12.3 Applications of LDR ..................................................64
3.13 Keypad Matrix......................................................................... 65
3.13.1 Single-Dimensional Interfacing Approach of
Switches...................................................................... 65
3.13.2 Algorithm to Find Out Which Switch is Pressed
in Single-Dimensional Interfacing Approach ............66
3.13.3 Disadvantage of Single-Dimensional Interfacing
Approach ....................................................................66
3.13.4 Two-Dimensional Interfacing Approach
of Switches .................................................................66
3.13.5 Algorithm to Find Out Which Switch is
Pressed in Two-Dimensional Interfacing
Approach (Key Matrix) ..............................................66
3.13.6 A 4 × 4 Keypad ........................................................... 68
3.14 Optical Sensor ......................................................................... 70
3.14.1 Retro-Reflective Optical Sensor ................................. 70
3.14.2 Retro-Reflective Optical Sensor Module ................... 72
3.15 Capacitive Touch Sensor.......................................................... 73
3.15.1 Capacitive Touch Sensor Working Principle .............. 74
3.15.2 Capacitive Touch Sensor Module ............................... 75
3.16 Gas Sensor ............................................................................... 76
3.16.1 Working of the Gas Sensor (MQ2)............................. 77
3.16.2 Gas Sensor Module (MQ2) ........................................ 77
3.16.3 Calibration of Gas Sensor (MQ2) Module ................. 78
3.17 Rain Detector Sensor (FC-07)................................................. 78
3.17.1 Rain Board ................................................................. 78
3.17.2 Rain Sensor Control Board ........................................ 78
3.17.3 Working of Rain Detector Sensor (FC-07) ................ 79
3.18 Ultrasonic Sensor (HC-SR04) .................................................80
3.18.1 Pin Description and Other Details of Ultrasonic
Sensor Module (HC-SR04) ........................................80
3.18.2 Working Principle of Ultrasonic Sensor Module
(HC-SR04) .................................................................. 81
viii Contents

3.19 Bluetooth Module (HC-05) ..................................................... 83


3.19.1 Pin Description and Other Details
of Bluetooth Module (HC-05) ....................................84
3.20 GSM Module (SIM900A) ........................................................ 85
3.21 Soil Moisture Sensor (YL-69) ................................................. 86
3.21.1 Moisture-Sensing Probe Module................................ 86
3.21.2 Moisture-Sensing Control Module ............................. 87
3.21.3 Working of Moisture Sensor ...................................... 88

Chapter 4 Interfacing and Programming with Arduino ..................................... 93


Learning Outcomes ............................................................................ 93
4.1 LED Interfacing and Programming ........................................ 93
4.2 Display in Serial Monitor ........................................................ 98
4.3 Push-Button Interfacing and Programming .......................... 105
4.4 Seven-Segment Display Interfacing and Programming ........ 112
4.5 Miscellaneous Programs Related to LED ............................. 125
4.6 LCD Interfacing and Programming ...................................... 131
4.7 Potentiometer Interfacing and Programming ........................ 140
4.8 Arduino Programming Using PWM Techniques .................. 150
4.9 Interfacing and Programming of Arduino with LM35 ......... 157
4.10 Interfacing and Programming of Arduino with
Humidity and Temperature Sensor DHT11 ........................... 163
4.11 Interfacing and Programming of Arduino
with DC Motor ...................................................................... 168
4.12 Interfacing and Programming of Arduino with
High-Voltage Device and Relay............................................. 183
4.13 Interfacing and Programming of Arduino UNO with
Light-Dependent Resistor (LDR) .......................................... 189
4.14 Interfacing and Programming of Arduino UNO with
4 × 4 Keypad .......................................................................... 194
4.15 Interfacing and Programming of Arduino UNO with
Optical Sensor ....................................................................... 201
4.16 Interfacing of Capacitive Touch Sensor with
Arduino UNO ........................................................................208
4.17 Interfacing and Programming of Arduino UNO with
Smoke Detector Sensor ......................................................... 213
4.18 Interfacing and Programming of Arduino UNO with
Rain Detector Sensor (FC-07)............................................... 217
4.19 Interfacing and Programming of Arduino UNO with
Ultrasonic Sensor (HC-SR04) ............................................... 221
4.20 Interfacing and Programming of Arduino UNO with
Bluetooth Module (HC-05) ...................................................224
4.21 Interfacing and Programming of Arduino UNO with
GSM Module (SIM900A) ...................................................... 228
Contents ix

4.22 Interfacing and Programming of Arduino UNO Using


I2C Protocol........................................................................... 231

Chapter 5 ­Arduino-Based Projects.................................................................... 235


5.1 ­Arduino-Based Obstacle Detection and Warning System..... 235
5.2 ­Arduino-Based Gas Leakage Detection................................. 238
5.3 Arduino-Based Burglar Detection.........................................240
5.4 ­Arduino-Based Weather Monitoring System......................... 243
5.5 ­Arduino-Based Mobile ­Phone-Controlled Light.................... 247
5.6 ­Arduino-Based Plant Watering System.................................. 250

Appendix 1: Answers to Check Yourself............................................................ 255


References.............................................................................................................. 257
Index....................................................................................................................... 259
Preface
This book provides a platform to the beginners to get started with the development
of application by using Arduino UNO board. The objective of this book is to provide
programming concepts of Arduino UNO board along with the working and interfac-
ing of sensors, input/output devices, communication modules, and actuators with
Arduino UNO board.
Arduino is an open-source hardware, which can be used to develop embedded
systems with the help of open-source software. Arduino has gained huge popularity
among the students and hobbyists for making a working model. The reasons behind
the popularity of Arduino are its low cost, availability of software, and easy-to-inter-
face possibility.
When someone is working with Arduino, he needs knowledge of three domains.
First, he must understand the Arduino hardware board. Second, he must understand
the Integrated Development Environment (IDE) required for the development of
software, which actually guides the hardware to perform the desired task. Third, he
must understand the working principle of various sensors, input and output devices,
and actuators, which may be required to gather information from the surrounding for
the processing by Arduino. The contents of this book are developed in keeping of
the view of providing all information which is required for enhancing the expertise
of all the domains required for the development of prototypes by using Arduino and
associated peripherals. This book will be helpful in the development of employability
skills in engineering undergraduate students.
After carefully understanding the exact requirements of the students and begin-
ners, I am quite confident that easy-to-understand language of this book will make
them efficient to learn Arduino. An outstanding and distinguished feature of this
book is large number of programs with description and interfacing diagram associ-
ated with each program.

BOOK ORGANIZATION
This book starts with the explanation of Arduino UNO board and Integrated
Development Environment (IDE). Various constructs required for the development
of software are also covered. The working principle of various sensors is explained in
depth; programming and interfacing examples with Arduino are taken up and finally
some moderate-level projects.
Chapter 1 “Introduction to Arduino UNO Board” gives a detailed informa-
tion regarding various components mounted on Arduino UNO board, IDE, and
ATmega328 microcontroller.
Chapter 2 “Arduino Programming Constructs” gives an in-depth understanding
of various constructs required for the programming of Arduino. Readers will also
learn in this chapter about various operators, data types, and functions, which will be
helpful to them when they start developing software for some specific applications.

xi
xii Preface

Chapter 3 “I/O Devices, Actuators, and Sensors” deals with the construction and
working of various sensors, input devices, output devices, and actuators. The readers
will learn in this chapter the working principle and function of various pins of LED,
seven-segment display, liquid crystal display (LCD), temperature sensor (LM35),
humidity and temperature sensor (DHT11), light-dependent register, touch sensor,
smoke detector (MQ2), rain detector (FC-07), ultrasonic sensor (HC-SR04), soil
moisture sensor (YL-69), Bluetooth module (HC-05), GSM module (SIM 900A),
switch, keypad matrix, potentiometer, analog-to-digital converter IC, motor driver
board (L293D), and relay board.
Chapter 4 “Interfacing and Programming with Arduino” gives detailed information
about how to interface input and output devices, viz., switch, keypad matrix, LED,
seven-segment display, liquid crystal display (LCD) with Arduino UNO board, and
the process of developing application programs for the interfaced circuit.
Chapter 5 “Arduino-Based Projects” covers interfacing and programming
concepts with a large number of circuit diagrams of few projects based on Arduino.
All efforts have been made to keep this book free from errors. I sincerely feel
that this book proves to be useful and helpful to the students for understanding
the interfacing and programming of Arduino. Constructive criticism and sugges-
tions from faculty members and dear students will be highly appreciated and duly
acknowledged.

Dr. Yogesh Misra


Acknowledgments
I would like to express my deep sense of gratitude to Dr. Girish J, Director Education,
GMR Varalakshmi Foundation; Dr. C.L.V.R.S.V Prasad, Principal, GMR Institute of
Technology, Andhra Pradesh, India; and Dr. M.V Nageshwara Rao, HOD, Department
of ECE, GMR Institute of Technology, Andhra Pradesh, India, for their continuous
substantial co-operation, motivation, and support; without them, this work would not
have been possible.
My special thanks to all my colleagues for helping me in reaching the logical
conclusion of my idea in the form of this textbook.
I am indebted to my dear students as the interaction with them helped me a lot in
understanding their needs.
Expressing gratitude publicly to wife is almost missing in Hindu society but I
would like to extend my sincere thanks and appreciation to my wife Dr. Pratibha
Misra for sparing me from day-to-day work for completing this work. I am also
thankful to my son Ishan and daughter Saundarya for providing me special ideas
about this book.
I acknowledge the support from Arduino for using their product images and data
to demonstrate and explain the working of the systems. I thank Taylor & Francis/
CRC Press team for encouraging and supporting me continuously to complete my
idea about this book.
Utmost care is taken for the circuits and programs mentioned in the text. All the
programs are tested on real hardware but in case of any mistake, I extend my sincere
apologies. Any suggestions to improve the contents of this book are always welcome
and will be appreciated and acknowledged.
I am also very much thankful to all who are directly or indirectly involved in the
accomplishment of this task.

Dr. Yogesh Misra

xiii
Author
Dr. Yogesh Misra, BE (Electronics), ME (Electronics & Communication
Engineering), and Ph.D., has a passion for teaching. He is having 24 years of teaching
and industrial experience. He is currently working as a Professor in the NBA accred-
ited Electronics & Communication Engineering Department of GMR Institute of
Technology, Rajam (Autonomous NAAC “A” Grade Institution) affiliated to JNTU,
Kakinada, Andhra Pradesh, India. All the seven programs offered by GMR Institute
of Technology are accredited by NBA. GMR Institute of Technology is ranked in the
band of 200 to 250 at the national level by NIRF, MHRD, New Delhi in June 2020.
Dr. Misra switched to academics in the year 2003 and worked in KL University,
Andhra Pradesh, Mody University, Rajasthan, and BRCM College of Engineering
and Technology, Haryana. He worked in Automatic Electronic Control System
(a sugar mill automation company) as an Engineer (Installation & Commissioning)
for many years.
He has conducted a number of workshops for the students/faculties on topics
Interfacing and Programming of Arduino, Circuit Designing using PSPICE
OrCAD, PCB Designing & Fabrication, Application of VHDL in System Design,
Microprocessor and Microcontroller Programming, VLSI Embedded Computing.
He has delivered expert lectures in different institutes on topics Interfacing and
Programming of Arduino, Embedded System Design, IC Manufacturing, FPGA
Architecture and Application, Fuzzy Logic and its Applications and Motivating
youth for Entrepreneurship. He has delivered lectures in AICTE-ISTE Refresher
programs and UGC sponsored seminars.
He has published more than 30 research papers and the majority of his papers are
in the field of VLSI design, soft computing, and embedded systems.
He has authored two books titled Digital System Design using VHDL with the
Dhanpat Rai Publication Co. in 2006 and Application of fuzzy logic in sugar mill
with the Lambert Academic Publishing in 2017.
Dr. Misra declared one of the toppers in the “Microprocessors and Microcon-
trollers” Course conducted by NPTEL, IIT Kharagpur.
He has made the following popular video lecture series:

xv
Abbreviations Used
in This Book
V Volt
mV Millivolt
A Ampere
µA Microampere
mA Milliampere
ms Millisecond
µs Microsecond
MΩ Mega Ohm
ppm Parts per million
cm Centimeter

xvii
1 Introduction to
Arduino UNO Board

LEARNING OUTCOMES
After completing this chapter, learners will be able to:

1.1 FEATURES OF ARDUINO UNO BOARD


Arduino is open-source hardware that can be used to develop embedded systems
with open-source software. Arduino has gained massive popularity among students
and hobbyists for making a working model. The reasons behind the popularity of
Arduino are its low cost, availability of software, and easy-to-interface possibility.
This book has used the Arduino UNO board’s code because it is the most popular
board in the Arduino family. The Arduino UNO is a microcontroller-based board
having an ATmega328 microcontroller from ATmega (now MicrochipTM). Most of
the Arduino boards have the majority of components, as shown in Figure 1.1. The
input voltage range required for the Arduino UNO board’s operation is 6–20 V, but
the recommended input voltage range is 7–12 V. If the input voltage is less than 7 V,
the digital output pins may supply less than 5 V, and the board may be unstable. The
output current from each pin of Arduino UNO is 40 mA.
Power USB (Label 1): Arduino board can be powered on by connecting it to the
computer at the USB socket using USB cable as shown in Label 1.
Power Connector (Label 2): Arduino board can be powered on by connecting it to
220 V AC by an adapter at Power Connector as shown as Label 2.
Voltage Regulator (Label 3): The voltage regulator shown in Label 3 is used to
regulate the Arduino board’s DC voltage.
Crystal Oscillator (Label 4): A crystal oscillator of 16 MHz is used in the Arduino
UNO board to synchronize the microcontroller’s various operations of ATmega 328
and Arduino UNO board.

1
2 Programming and Interfacing with Arduino

­FIGURE 1.1 Arduino UNO board. (Courtesy Arduino.)

Reset (Label 5): Sometimes, a program may be stuck at some instruction. In such
cases, we have to reset our Arduino board so that the program’s execution should
start from the beginning. If a 0 V is applied at the reset pin as shown in Label 5, the
Arduino board will reset. An alternate way to reset the Arduino board is by pressing
the reset button, as shown in Label 17.
3.3 V (Label 6): The 3.3V output is available at the pin as shown in Label 6.
5 V (Label 7): The 5V output is available at the pin as shown in Label 7.
GND (Label 8): In the Arduino board, three GND (ground) pins are available.
Users can use any available ground pin while building their circuit. The two GND
(ground) pins are available at the pins, as shown in Label 8. The third GND (ground)
pin is available at the right-side pin, as shown in Label 16.
Vin (Label 9): Arduino board can be powered on by connecting a DC voltage in
the range of 7–20 V at Vin pin, as shown in Label 9.
Analog Input (Label 10): The Arduino UNO board contains six analog pins
named A0, A1, A2, A3, A4, and A5. Internally, these analog pins are connected to
a six-channel 10-bit analog-to-digital converter. The allowable analog input voltage
range at each analog input pin is 0 –5 V. Since each analog input pin is connected to
a 10-bit analog-to-digital converter, 0–5 V is divided into 1,024 steps ranging from 0
to 1,023. The six analog pins are shown in Label 10.
ATmega328 (Label 11): The ATmega328 microcontroller is used to perform
various arithmetic and logical operations. The ATmega328 microcontroller is
manufactured by Atmel Company and shown in Label 11.
Introduction to Arduino UNO Board 3

ICSP (Label 12): It is a small programming header for the Arduino consisting
of MOSI (Master Output Slave Input), MISO (Master Input Slave Output), SCLK
(System Clock), RESET, VCC, and GND.
Power LED (Label 13): When the Arduino board is power on, the power LED
turns on. The Power LED is shown in Label 13.
Tx and Rx LEDs (Label 14): When the Arduino board transmits data serially from
the Arduino board through Pin 1 of the Arduino board, Tx (Transmit) LED blinks.
When the Arduino board receives data serially through Pin 0 of the Arduino
board, Rx (Receive) LED blinks. The Tx and Rx LEDs are shown in Label 14.
Digital I/O (Label 15): The Arduino UNO board has 14 digital I/O (input/output)
pins. Each of these pins can be configured as an input or output pin by using the
pinMode function.[1] If the pin is configured as an input pin, then the digital signal
can be applied on the pin, and if the pin is configured as an output pin, then the
digital signal will output on the pin. The digital I/O pins are shown in Label 15.[2]
There are six pins in the Arduino UNO board, namely, 3, 5, 6, 9, 10, and 11, with
Pulse Width Modulation (PWM) capabilities. The six PWM pins are labeled as “~”.
Serial data transfer uses Pins 0 and 1. Pin 0 of the Arduino board can be used to
receive data serially, and Pin 1 of the Arduino board can be used to transmit data
serially. If Pins 0 and 1 are not used in serial data transfer, they can be used as
digital I/O pins.
AREF (Label 16): AREF (Analog Reference) pin is sometimes used with analog
input pins A0–A5. If we wish to set an external reference voltage for A0–A5 analog
pins other than 0 to 5 V, we need an AREF pin. The AREF pin is shown in Label 16.

1.2 ARDUINO IDE SOFTWARE


The IDE is the software used for the development of programs. The IDE for high-level
language (Embedded C)-based development flow is shown in Figure 1.2. The func-
tion of various components of IDE is shown in the following.

1.2.1 Editor
­

1.2.2 CompilEr
Compiler is a program that converts high-level language program into binary lan-
guage. The object file (.o) is generated by the compiler in Arduino and .obj file for the
source file of C/C++. The name of the compiler in Arduino IDE is AVR-GCC. The
cross-compiler used in Keil µVision IDE is C51.

1.2.3 linkEr
The purpose of a linker is to link more than one object file of the same project into
one object file.
4 Programming and Interfacing with Arduino

F­ IGURE 1.2 The process flow of software development using a high-level language
(Embedded
­ C).

1.2.4 loCator
The locator’s purpose is to assign the memory address of code memory to the instruc-
tions. Locator generates Absolute Object file. The avr-ld utility is used for Linker/
Locator in Arduino IDE. The Linker/ Locator used in Keil µVision IDE is BL51.

1.2.5 HEx ConvErtEr


This software converts the Absolute Object file into a hexadecimal file with .hex
extension. Avr-object copy utility is used to convert object files to the hex file in
Arduino IDE.

1.2.6 loadEr
Loader software is used to load the hexadecimal file into the target controller. The
avr-dude utility is used for Linker/ Locator in Arduino IDE.

1.3 ARDUINO IDE DOWNLOAD


The steps to download the IDE for the development of programs are as follows:

Step 1: Go to www.arduino.cc website.


Step 2: Go to the “DOWNLOADS” option of the “SOFTWARE” menu.
Step 3: We shall be directed to the “Download the Arduino IDE” option.
Step 4: Click the “Windows Installer for Windows XP and up” option.
Introduction to Arduino UNO Board 5

Step 5: We shall be directed to the “Contribute to the Arduino Software” page.


Step 6: We shall get the “Just Download” and “Contribute & Download” option.
Step 7: After installing the .exe file, an icon of Arduino will be created on the
desktop.

1.4 WORKING WITH ARDUINO IDE


The Arduino programs are called a sketch. A sketch is saved with extension .ino.
The steps to work with Arduino IDE for the development of programs are as follows:
Step 1: Open the editor window to write a program in Arduino IDE. The
screenshot of Step 1 is shown in Figure 1.3.
Step 2: Select the Arduino/Genuino UNO board from the “Board” option of
“Tools”. The screenshot of Step 2 is shown in Figure 1.4.
Step 3: Follow the procedure to know the serial port to which Arduino is
mapped (Figure
­­ 1.5):
i. Right-click on My Computer.
ii. Select the Manage option.
iii. In the pop-up screen for Computer Management, select the Device
Manager.
iv. Expand the Ports item; the Arduino UNO will appear as one of the
­drop-down items.
Step 4: In the Arduino IDE, select the “port” in the “Tool” option, and check
“COM6 (Arduino/Genuino Uno)” as shown in Figure 1.6.
Step 5: The “verify”, “upload”, and “serial monitor” buttons on the sketch are
shown in Figure 1.7. The functions of “verify”, “upload”, and “serial moni-
tor” buttons are as follows:
i. The “verify” button is used to compile the program. If there are
errors, the line numbers of the errors are shown in the bottom window.
Correct the errors, and again click the “verify” button.

­FIGURE 1.3 The screenshot for Step 1.


6 Programming and Interfacing with Arduino

­FIGURE 1.4 The screenshot for Step 2.

­FIGURE 1.5 The screenshot for Step 3.


Introduction to Arduino UNO Board 7

­FIGURE 1.6 The screenshot for Step 4.

­FIGURE 1.7 The screenshot for Step 5.

ii. Once the compilation is done, upload the program from the computer to
the Arduino board by clicking the “upload” button. During the upload-
ing process, the Arduino board must be connected to the computer via
USB cable.
iii. To display the values, click the “serial monitor” button.

1.5 INTRODUCTION TO ATMEGA 328


The ATmega328 microcontroller was manufactured by Atmel Company; later,
Atmel was acquired by Microchip Technology in 2016. It is an 8-bit RISC (Reduces
Instruction Set Computer) architecture-based microcontroller. ATmega328 is a
28-pin IC having Harvard-based architecture.
8 Programming and Interfacing with Arduino

­FIGURE 1.8 The pin mapping of ATmega328 with Arduino UNO board.

The ATmega328 microcontroller is most commonly used in the Arduino UNO


board. The pin detail of ATmega328 and the pin mapping of ATmega 328 with the
Arduino board are shown in Figure 1.8.
The ATmega328 has three ports, namely, Port B, Port C, and Port D. The three
ports of ATmega328 comprise 23 pins. Port B is an 8-bit port, namely, PB0–PB7;
Port C is a 7-bit port, namely, PC0–PC6; and Port D is an 8-bit port, namely, PD0–
PD7. There are two ground pins available at Pins 8 and 22, one Vcc pin at Pin 7, Aref
(analog reference) at Pin 21, and AVcc (analog Vcc) at Pin 20. The PB6 and PB7 pins
of ATmega328 are used to connect external crystal.
Features of ATmega328:

i. It is based on RISC architecture.


Introduction to Arduino UNO Board 9

1.6 SERIAL PERIPHERAL INTERFACE (SPI)


COMMUNICATION PROTOCOL
The SPI is a synchronous serial communication protocol since master and slave
both share the same clock.[3] It is suitable for interfacing microcontrollers with
sensors/display/memory devices. Master is controlling devices like microcon-
trollers, and slaves take instructions from the master. The signals of SPI protocols
are MOSI, MISO, SCLK, and SS/CS (Slave Select/Chip Select). The SS/CS signal
is active low.
Slave Select: Master can select the slave with which it wants to communicate by
setting the SS/CS line at a low level. In idle conditions, the SS/CS line is kept at
a high-voltage level. The master sends data to the slave bit by bit, in a serial form
through the MOSI line, and the slave receives data sent from the master at the MOSI
pin.[4] Data sent by the master to slave is usually with MSB (most significant bit) first.
The slave can also send back data to the master through the MISO pin.[1] Data sent
by the slave to master is usually with LSB (least significant bit) first. There is a sin-
gle master and single slave in the simple SPI configuration, as shown in Figure 1.9.
Multiple SS/CS lines may be available in the master, allowing multiple slaves to be
connected in parallel, as shown in Figure 1.10. If only one SS/Cs line is available in
master, then multiple slaves can be connected in the Daisy-chaining method as shown
in ­Figure 1.11.

1.6.1 StEpS of Spi data tranSmiSSion – tHE StEpS for data


tranSmiSSion in Spi protoColS arE aS followS:
i. Master outputs clock signal through the SCLK pin.
ii. Master switches the SS/CS pin to a low-voltage state, which activates the slave.

­FIGURE 1.9 The simplest SPI configuration.


10 Programming and Interfacing with Arduino

­FIGURE 1.10 Multiple slaves connected to master having multiple SS/CS pins.

­FIGURE 1.11 Multiple slaves connected to master having single SS/CS pins.
Introduction to Arduino UNO Board 11

1.6.2 advantagES of Spi data tranSmiSSion – tHE advantagES of


data tranSmiSSion in Spi protoColS arE aS followS:
i. No start and stop bit required.

1.6.3 diSadvantagES of Spi data tranSmiSSion – tHE diSadvantagES


of data tranSmiSSion in Spi protoColS arE aS followS:

1.7 ­INTER-INTEGRATED CIRCUIT (I2C)


­
COMMUNICATION PROTOCOL
The I2C serial communication protocol was invented by Phillips in 1982. The I2C pro-
tocol can connect multiple slaves to a single master or multiple slaves to multiple mas-
ters. The I2C protocol can be used when two microcontrollers send data to the same
memory or send data to the same LCD, and there can be many more applications. The
I2C serial communication protocol has two signals: Serial Data (SDA) and Serial Clock
(SCL). The master and slave send and receive data through the SDA line, and SCL is
the clock signal line. The master always controls the clock signal. The single master and
single slave connections of the I2C protocol are shown in Figure 1.12, and the single
master and multiple slave connections of the I2C protocol are shown in Figure 1.13.
The message frame of the I2C serial communication protocol is shown in
­Figure 1.14.[1] The various fields of the frame are as follows:

Start Condition: The SDA line switches from a high-voltage level to a


low-voltage level before the SCL line switches from high to low.[1]
Stop Condition: The SDA line switches from a low-voltage level to a
high-voltage level after the SCL line switches from low to high.[1]

­FIGURE 1.12 Single master and slave connection in I2C protocol.


12 Programming and Interfacing with Arduino

­FIGURE 1.13 The single master and multiple slaves connection in I2C protocol.

­FIGURE 1.14 The message frame of I2C protocol.


Introduction to Arduino UNO Board 13

Address Frame: A 7 or 10-bit sequence unique to each slave identifies the slave
when the master wants to talk to it.[1]
Read/Write
­ Bit: A single bit specifying whether the master is sending data to
the slave (low-voltage level) or requesting data from it (high-voltage level).[1]
ACK/NACK
­ Bit: Each frame in a message is followed by an acknowledge/-
no-acknowledge bit. If an address frame or data frame was successfully
received, an ACK bit is returned to the sender from the receiving device.[1]

Check Yourself

a. 64 Kbytes of programmable flash memory


b. ATmega328 microcontroller
c. 2 Kbytes of SRAM
d. 16 MHz clock
2 Arduino Programming
Constructs

LEARNING OUTCOMES
After completing this chapter, learners will be able to:

2.1 STRUCTURE OF ARDUINO PROGRAMMING


Each Arduino program must have two functions as shown below:

void setup()
{
}
void loop()
{
}

2.1.1 Setup()
The setup() function is called when the Arduino program starts. It will run only
once, after each power-up or reset of the Arduino board. Setup() function is used
to initialize variables, pin modes, libraries, serial communication, etc.

2.1.2 Loop()
The loop() function executes an infinite number of times until the Arduino board is
getting power. It is used to control various devices using the Arduino board.

2.1.3 variablES
All variables have to be declared before they are used. An object of the variable class
holds a single value of a specified type. However, different values can be assigned
15
16 Programming and Interfacing with Arduino

to the variable by using variable assignment statements. Declaring a variable means


defining its type, and optionally, setting an initial value (initializing the variable).
Syntax of variable object declaration:

t
­ ype-name name-of-object
­ ­ = initial-value;
­

Example:

int LED = 13;

In the above statement, LED has declared a variable that holds the integer-type
value, and its initial value is 13. The value of the LED variable can be changed
later on.

2.1.4 ConStant
All constants have to be declared before they are used. An object of the constant class
holds a single value of a specified type. The value of the constant cannot be changed
in the program. Declaring a constant means defining its type, and optionally, setting
an initial value (initializing the constant). Syntax of variable object declaration:

const ­type-name ­name-of-object


­ = ­initial-value;

Example:

const int MY_LED = 13;

In the above statement, MY_LED is declared a constant that holds the value of the
integer type, and its initial value is 13. The value of the MY_LED constant cannot
be changed later on.

2.1.5 intEgEr
The values of integer types fall within the specified range of integers. The values of
integer type at least cover a range from (−32,368 to +32,367). The values of integer
types are called integer literals.

2.2 FUNCTION
A function is a name given to a group of code that performs some specific work.

2.2.1 pinMode(pin, Mode)

The pinMode function is used to configure the specified pin as input or output.
The pinMode function has two arguments, i.e., pin and mode. The argument pin
is used to specify the pin whose mode we wish to set. The argument mode can be
assigned either as input or as output by writing INPUT or OUTPUT, respectively.
Arduino Programming Constructs 17

Example 2.1

A LED is connected to Pin 13 of Arduino UNO. Write a program to declare Pin 13


as an output pin.

Solution:
A program (Method I) to declare Pin 13 as an output pin is shown in Figure 2.1.

int LED = 13; statement (1)


void setup()
{
pinMode(LED,OUTPUT); statement (2)
}

F­ IGURE 2.1 An Arduino program to assign the name “LED” to Pin 13 of the Arduino
board and initialize it as an output pin.

Description of Program shown in Figure 2.1:

In the statement (1), LED is declared a variable that holds the value of integer
type, and its value is assigned as 13.
Inside setup() in statement (2), the pinMode function declares the LED
variable as an output pin. Since Pin 13 is assigned to variable LED in state-
ment (1), due to statement (2), Pin 13 is initialized as an output pin.

An alternate program to declare Pin 13 as the output pin is shown in Figure 2.2.
void setup()
{
pinMode(13,OUTPUT); statement (1)
}

F­ IGURE 2.2 An Arduino to initialize Pin 13 of Arduino board as an output pin with-
out assigning it any name.

Description of Program as shown in Figure 2.2:

Inside setup() in the statement (1), the pinMode function is used to initial-
ize Pin 13 as the output pin. Since we are using pin number directly in the
pinMode function, there is no need for statement (1) of the Method I program.

2.2.2 digitaLWrite(pin, vaLue)

The digitalWrite function is used to set the pin configured as an output pin using
pinMode function to either a HIGH or a LOW state. The digitalWrite function
has two arguments, i.e., pin and mode. The argument pin is used to specify the pin
whose mode we wish to set.
18 Programming and Interfacing with Arduino

Example 2.2

The anode of LED is connected to Pin 13 of Arduino UNO, and the cathode of LED
is connected to the ground. Write a program to on the LED.

Solution:
A program to on the LED connected to Pin 13 is shown in Figure 2.3.

int LED = 13; statement (1)


void setup()
{
pinMode(LED,OUTPUT); statement (2)
}
void loop()
{
digitalWrite(LED,HIGH); statement (3)
}

­FIGURE 2.3 An Arduino to turn on the LED connected to Pin 13 of Arduino board.

Description of Program:
The statement (1) LED is declared a variable that holds the value of integer
type, and its value is assigned as 13. By using statement (1), we wish to give
the name LED to Pin 13.
Inside setup() in the statement (2), the pinMode function declares Pin 13
as an output pin. Since Pin 13 is assigned to variable LED in statement (1),
in the statement (2), we have used the LED name of Pin 13 for initializing
it as an output pin.
Inside loop(), the digitalWrite function in the statement (3) is used
to set Pin 13 to HIGH. Due to statement (3), Pin 13 will be set at 5 V.
Since the anode and cathode of LED are connected to Pin 13 and GND
(ground) of Arduino UNO board, respectively, after the execution of the
digitalWrite(LED, ­ HIGH) statement, the LED will on.

2.2.3 digitaLread(pin)

The digitalRead(pin) ­ function reads the digital value from the specified pin,
which is given in the argument of the digitalRead function. This function returns
the value either high (5 V/logic 1) or low (0 V/logic 0).

Example 2.3

Declare Pin 13 of Arduino UNO as an input pin, and read the digital value avail-
able at this pin.

Solution:
A program to declare Pin 13 of Arduino UNO as an input pin and read the digital
value available at this pin is shown in Figure 2.4.
Arduino Programming Constructs 19

int SWITCH = 13; statement (1)


void setup()
{
pinMode(SWITCH,INPUT); statement (2)
}
void loop()
{
int VALUE = 0; statement (3)
VALUE = digitalRead(SWITCH); statement (4)
}

F­ IGURE 2.4 An Arduino to initialize Pin 13 of Arduino board as an input pin and
read its value.

Description of Program:

In statement (1), SWITCH has declared a variable that holds the value of inte-
ger type, and its value is assigned as 13. By using statement (1), we wish to
give the name SWITCH to Pin 13.
Inside setup() in the statement (2), the pinMode function declares Pin 13 as
the input pin. Since Pin 13 is assigned to variable SWITCH in statement (1),
in the statement (2), we have used the SWITCH name of Pin 13 for initial-
izing it as an input pin.
Inside loop(), the statement (3) is used to declare SWITCH as a variable that
holds the value of integer type, and its value is assigned as 0.
Inside loop(), the digitalRead function in the statement (4) is used to read
the digital value of input Pin 13 (named SWITCH). The digital value read
from Pin 13 is assigned to the variable VALUE.

2.2.4 anaLogread(pin)

The analogRead(pin) function reads the analog value from the specified analog
pin as given in the analogRead function’s argument. The Arduino board contains six
analog pins named A0, A1, A2, A3, A4, and A5. Internally, these analog pins are
connected to a six-channel 10-bit analog-to-digital converter. The allowable analog
input voltage range at each analog input pin is 0 –5 V. Since each analog input pin is
connected to a 10-bit analog-to-digital converter, 0–5 V is divided into 1,024 steps.
So there are 1,024 steps ranging from 0 to 1,023 steps. The analogRead function
returns an integer value in the range of 0–1,023.
* Please refer to Section 3.6 of Chapter 3 for analog-to-digital converter.

Example 2.4

Declare the Pin A0 of Arduino UNO as an input pin, and read the analog value
available at this pin.

Solution:
A program to declare the Pin A0 of Arduino UNO as an input pin and read the
analog value available at this pin is shown in Figure 2.5.
20 Programming and Interfacing with Arduino

int SIGNAL = A0; statement (1)


void setup()
{
pinMode(SIGNAL,INPUT); statement (2)
}
void loop()
{
int myValue = 0; statement (3)
myValue = analogRead(SIGNAL); statement (4)
}

F­ IGURE 2.5 An Arduino to initialize analog Pin A0 of Arduino board as an input


pin and read its value.

Description of Program:

In the statement (1), SIGNAL has declared a variable that holds the value of
integer type, and its value is assigned analog Pin A0.
Inside setup() in the statement (2), the pinMode function declares the A0
analog pin as an input pin.
Inside loop(), the statement (3) is used to declare myValue as a variable that
holds the value of integer type, and its value is assigned as 0.
Inside loop(), the analogRead function in the statement (4) is used to read
the input Pin A0’s analog value and named as SIGNAL. The analog value
read from Pin A0 is assigned to variable myValue. The value assigned to
myValue will be in the range from 0 to 1,023.

2.2.5 anaLogWrite(pin, vaLue)

The analogWrite function is used to write an analog value to pulse width mod-
ulation ( PWM) pins. There are six pins in the Arduino UNO board, namely, 3, 5,
6, 9, 10, and 11, with PWM capabilities. The analogWrite function is not asso-
ciated with any of the six analog input pins A0–A5. The analogWrite function
has two arguments, i.e., pin and value. The argument pin is used to specify the
PWM pin, and the argument value can have a value from 0 to 255. The analog-
Write writes the value from 0 to 255 in the PWM pin. The analogWrite
function can light an LED at varying brightness or drive a motor at various
speeds. Readers can find programs related to PWM concepts in chapter 4.

2.2.6 deLay(vaLue)

The delay is a function that generates a delay for a specified amount of time.
The delay function has one argument, and it generates a delay equal to the value
of the argument in millisecond (ms). The generation of delay means the micro-
controller will be engaged in executing a few sets of instructions for the specified
amount of time. The microcontroller will execute the next instruction written after
the delay function only after the specified time, as mentioned in the delay func-
tion’s argument.
Arduino Programming Constructs 21

2.2.7 for loop

The for loop is used to repeat a group of statements enclosed in curly brackets. The
for statement is useful for executing a group of statements unless a condition meets.
The syntax of for loop statement is as follows[4]:

for (initialization; condition; increment)


{
­ ­
//statement(s);
}

The initialization happens first and exactly once. Each time through the loop, the
condition is tested; if it’s true, the statement block and the increment are executed,
and the condition is tested again. When the condition becomes false, the loop ends.

2.2.8 SeriaL.begin(rate)
The begin function of the “Serial” library has one argument. Serial.begin
function is used to initialize the baud rate for serial communication. This function is
used to initiate the serial communication between the Arduino UNO board and other
devices like computer, sensor, input or output device, etc.
The integer-type value is allowed in the argument of the Serial.begin func-
tion. For example, the Serial.begin(9600) ­ will initialize the serial communica-
tion between the Arduino UNO board and other peripheral at 9,600 Baud. The 9,600
Baud signifies that the data will be communicated at the rate of 9,600 bits per second
during serial communication.
When the Arduino UNO board is initialized for serial communication, Pins 0
and 1 will be used for serial data transfer. Pin 0 of the Arduino board will be used
to receive data serially, and Pin 1 of the Arduino board will be used to transmit data
serially. If Pins 0 and 1 are not used in serial data transfer, then these pins can be
used as digital I/O pins. But if we are using Pins 0 and 1 for serial data transfer, then
these pins cannot be used as digital I/O pins.

2.2.9 SeriaL.print("arguMent")
The Serial.print function is used to print on serial monitor. The Serial.print
function has one argument, and it is placed between double quotes.
The “Serial.print("argument")” function will print the argument on the serial
monitor, and after printing, the cursor will remain in the same line.

2.2.10 SeriaL.printLn("arguMent")
The Serial.println function is also used to print on serial monitor. The Serial.
println function has one argument, and it is placed between double quotes.
The Serial.println("argument") function will print the argument on the
serial monitor, and after printing, the cursor will go to the next line.
Another Random Document on
Scribd Without Any Related Topics
because natural science reveals that a rapid transit system of
evolution is carrying us automatically to the goal of perfect man in
perfect society; and his English idealistic contemporary, Green, is so
disturbed by the removal from nature of its moral qualities, that he
tries to show that this makes no difference, since nature in any case
is constituted and known through a spiritual principle which is as
permanent as nature is changing. An Amiel genteelly laments the
decadence of the inner life, while his neighbor Nietzsche brandishes
in rude ecstasy the banner of brute survival as a happy omen of the
final victory of nobility of mind. The reasonable conclusion from such
a scene is that there is taking place a transformation of attitude
towards moral theory rather than mere propagation of varieties
among theories. The classic theories all agreed in one regard. They
all alike assumed the existence of the end, the summum bonum, the
final goal; and of the separate moral force that moves to that goal.
Moralists have disputed as to whether the end is an aggregate of
pleasurable state of consciousness, enjoyment of the divine essence,
acknowledgment of the law of duty, or conformity to environment.
So they have disputed as to the path by which the final goal is to be
reached: fear or benevolence? reverence for pure law or pity for
others? self-love or altruism? But these very controversies implied
that there was but the one end and the one means.
The transformation in attitude, to which I referred, is the
growing belief that the proper business of intelligence is
discrimination of multiple and present goods and of the varied
immediate means of their realization; not search for the one remote
aim. The progress of biology has accustomed our minds to the
notion that intelligence is not an outside power presiding supremely
but statically over the desires and efforts of man, but is a method of
adjustment of capacities and conditions within specific situations.
History, as the lecturer on that subject told us, has discovered itself
in the idea of process. The genetic standpoint makes us aware that
the systems of the past are neither fraudulent impostures nor
absolute revelations; but are the products of political, economic, and
scientific conditions whose change carries with it change of
theoretical formulations. The recognition that intelligence is properly
an organ of adjustment in difficult situations makes us aware that
past theories were of value so far as they helped carry to an issue
the social perplexities from which they emerged. But the chief
impact of the evolutionary method is upon the present. Theory
having learned what it cannot do, is made responsible for the better
performance of what needs to be done, and what only a broadly
equipped intelligence can undertake: study of the conditions out of
which come the obstacles and the resources of adequate life, and
developing and testing the ideas that, as working hypotheses, may
be used to diminish the causes of evil and to buttress and expand
the sources of good. This program is indeed vague, but only
unfamiliarity with it could lead one to the conclusion that it is less
vague than the idea that there is a single moral ideal and a single
moral motive force.
From this point of view there is no separate body of moral rules;
no separate system of motive powers; no separate subject-matter of
moral knowledge, and hence no such thing as an isolated ethical
science. If the business of morals is not to speculate upon man’s
final end and upon an ultimate standard of right, it is to utilize
physiology, anthropology, and psychology to discover all that can be
discovered of man, his organic powers and propensities. If its
business is not to search for the one separate moral motive, it is to
converge all the instrumentalities of the social arts, of law,
education, economics, and political science upon the construction of
intelligent methods of improving the common lot.
If we still wish to make our peace with the past, and to sum up
the plural and changing goods of life in a single word, doubtless the
term happiness is the one most apt. But we should again exchange
free morals for sterile metaphysics, if we imagine that “happiness” is
any less unique than the individuals who experience it; any less
complex than the constitution of their capacities, or any less variable
than the objects upon which their capacities are directed.
To many timid, albeit sincere, souls of an earlier century, the
decay of the doctrine that all true and worthful science is knowledge
of final causes seemed fraught with danger to science and to morals.
The rival conception of a wide open universe, a universe without
bounds in time or space, without final limits of origin or destiny, a
universe with the lid off, was a menace. We now face in moral
science a similar crisis and like opportunity, as well as share in a like
dreadful suspense. The abolition of a fixed and final goal and causal
force in nature did not, as matter of fact, render rational conviction
less important or less attainable. It was accompanied by the
provision of a technique of persistent and detailed inquiry in all
special fields of fact, a technique which led to the detection of
unsuspected forces and the revelation of undreamed of uses. In like
fashion we may anticipate that the abolition of the final goal and the
single motive power and the separate and infallible faculty in morals,
will quicken inquiry into the diversity of specific goods of experience,
fix attention upon their conditions, and bring to light values now dim
and obscure. The change may relieve men from responsibility for
what they cannot do, but it will promote thoughtful consideration of
what they may do and the definition of responsibility for what they
do amiss because of failure to think straight and carefully. Absolute
goods will fall into the background, but the question of making more
sure and extensive the share of all men in natural and social goods
will be urgent, a problem not to be escaped nor evaded.
Morals, philosophy, returns to its first love; love of the wisdom
that is nurse, as nature is mother, of good. But it returns to the
Socratic principle equipped with a multitude of special methods of
inquiry and testing; with an organized mass of knowledge, and with
control of the arrangements by which industry, law, and education
may concentrate upon the problem of the participation by all men
and women, up to their capacity of absorption, in all attained values.
Morals may then well leave to poetry and to art, the task (so
unartistically performed by philosophy since Plato) of gathering
together and rounding out, into one abiding picture, the separate
and special goods of life. It may leave this task with the assurance
that the resultant synthesis will not depict any final and all-inclusive
good, but will add just one more specific good to the enjoyable
excellencies of life.
Humorous irony shines through most of the harsh glances
turned towards the idea of an experimental basis and career for
morals. Some shiver in the fear that morals will be plunged into
anarchic confusion—a view well expressed by a recent writer in the
saying that if the a priori and transcendental basis of morals be
abandoned “we shall have merely the same certainty that now exists
in physics and chemistry”! Elsewhere lurks the apprehension that the
progress of scientific method will deliver the purposive freedom of
man bound hand and foot to the fatal decrees of iron necessity,
called natural law. The notion that laws govern and forces rule is an
animistic survival. It is a product of reading nature in terms of
politics in order to turn around and then read politics in the light of
supposed sanctions of nature. This idea passed from medieval
theology into the science of Newton, to whom the universe was the
dominion of a sovereign whose laws were the laws of nature. From
Newton it passed into the deism of the eighteenth century, whence it
migrated into the philosophy of the Enlightenment, to make its last
stand in Spencer’s philosophy of the fixed environment and the static
goal.
No, nature is not an unchangeable order, unwinding itself
majestically from the reel of law under the control of deified forces.
It is an indefinite congeries of changes. Laws are not governmental
regulations which limit change, but are convenient formulations of
selected portions of change followed through a longer or shorter
period of time, and then registered in statistical forms that are
amenable to mathematical manipulation. That this device of
shorthand symbolization presages the subjection of man’s intelligent
effort to fixity of law and environment is interesting as a culture
survival, but is not important for moral theory. Savage and child
delight in creating bogeys from which, their origin and structure
being conveniently concealed, interesting thrills and shudders may
be had. Civilized man in the nineteenth century outdid these
bugaboos in his image of a fixed universe hung on a cast-iron
framework of fixed, necessary, and universal laws. Knowledge of
nature does not mean subjection to predestination, but insight into
courses of change; an insight which is formulated in “laws,” that is,
methods of subsequent procedure.
Knowledge of the process and conditions of physical and social
change through experimental science and genetic history has one
result with a double name: increase of control, and increase of
responsibility; increase of power to direct natural change, and
increase of responsibility for its equitable direction toward fuller
good. Theory located within progressive practice instead of reigning
statically supreme over it, means practice itself made responsible to
intelligence; to intelligence which relentlessly scrutinizes the
consequences of every practice, and which exacts liability by an
equally relentless publicity. As long as morals occupies itself with
mere ideals, forces and conditions as they are will be good enough
for “practical” men, since they are then left free to their own devices
in turning these to their own account. As long as moralists plume
themselves upon possession of the domain of the categorical
imperative with its bare precepts, men of executive habits will
always be at their elbows to regulate the concrete social conditions
through which the form of law gets its actual filling of specific
injunctions. When freedom is conceived to be transcendental, the
coercive restraint of immediate necessity will lay its harsh hand upon
the mass of men.
In the end, men do what they can do. They refrain from doing
what they cannot do. They do what their own specific powers in
conjunction with the limitations and resources of the environment
permit. The effective control of their powers is not through precepts,
but through the regulation of their conditions. If this regulation is to
be not merely physical or coercive, but moral, it must consist of the
intelligent selection and determination of the environments in which
we act; and in an intelligent exaction of responsibility for the use of
men’s powers. Theorists inquire after the “motive” to morality, to
virtue and the good, under such circumstances. What then, one
wonders, is their conception of the make-up of human nature and of
its relation to virtue and to goodness? The pessimism that dictates
such a question, if it be justified, precludes any consideration of
morals.
The diversion of intelligence from discrimination of plural and
concrete goods, from noting their conditions and obstacles, and from
devising methods for holding men responsible for their concrete use
of powers and conditions, has done more than brute love of power
to establish inequality and injustice among men. It has done more,
because it has confirmed with social sanctions the principle of feudal
domination. All men require moral sanctions in their conduct: the
consent of their kind. Not getting it otherwise, they go insane to
feign it. No man ever lived with the exclusive approval of his own
conscience. Hence the vacuum left in practical matters by the
remote irrelevancy of transcendental morals has to be filled in
somehow. It is filled in. It is filled in with class-codes, class-
standards, class-approvals—with codes which recommend the
practices and habits already current in a given circle, set, calling,
profession, trade, industry, club, or gang. These class-codes always
lean back upon and support themselves by the professed ideal code.
This latter meets them more than half-way. Being in its pretense a
theory for regulating practice, it must demonstrate its practicability.
It is uneasy in isolation, and travels hastily to meet with compromise
and accommodation the actual situation in all its brute unrationality.
Where the pressure is greatest—in the habitual practice of the
political and economic chieftains—there it accommodates the most.
Class-codes of morals are sanctions, under the caption of ideals,
of uncriticised customs; they are recommendations, under the head
of duties, of what the members of the class are already most given
to doing. If there are to obtain more equable and comprehensive
principles of action, exacting a more impartial exercise of natural
power and resource in the interests of a common good, members of
a class must no longer rest content in responsibility to a class whose
traditions constitute its conscience, but be made responsible to a
society whose conscience is its free and effectively organized
intelligence.
In such a conscience alone will the Socratic injunction to man to
know himself be fulfilled.
THE EXPERIMENTAL THEORY OF
KNOWLEDGE
7

I
t should be possible to discern and describe a knowing as one
identifies any object, concern, or event. It must have its own
marks; it must offer characteristic features—as much so as a
thunder-storm, the constitution of a State, or a leopard. In the
search for this affair, we are first of all desirous for something which
is for itself, contemporaneously with its occurrence, a cognition, not
something called knowledge by another and from without—whether
this other be logician, psychologist, or epistemologist. The
“knowledge” may turn out false, and hence no knowledge; but this
is an after-affair; it may prove to be rich in fruitage of wisdom, but if
this outcome be only wisdom after the event, it does not concern us.
What we want is just something which takes itself as knowledge,
rightly or wrongly.

I
This means a specific case, a sample. Yet instances are
proverbially dangerous—so naïvely and graciously may they beg the
questions at issue. Our recourse is to an example so simple, so
much on its face as to be as innocent as may be of assumptions.
This case we shall gradually complicate, mindful at each step to
state just what new elements are introduced. Let us suppose a
smell, just a floating odor. This odor may be anchored by supposing
that it moves to action; it starts changes that end in picking and
enjoying a rose. This description is intended to apply to the course
of events witnessed and recounted from without. What sort of a
course must it be to constitute a knowledge, or to have somewhere
within its career that which deserves this title? The smell, imprimis,
is there; the movements that it excites are there; the final plucking
and gratification are experienced. But, let us say, the smell is not the
smell of the rose; the resulting change of the organism is not a
sense of walking and reaching; the delicious finale is not the
fulfilment of the movement, and, through that, of the original smell;
“is not,” in each case meaning is “not experienced as” such. We may
take, in short, these experiences in a brutely serial fashion. The
smell, S, is replaced (and displaced) by a felt movement, K, this is
replaced by the gratification, G. Viewed from without, as we are now
regarding it, there is S-K-G. But from within, for itself, it is now S,
now K, now G, and so on to the end of the chapter. Nowhere is
there looking before and after; memory and anticipation are not
born. Such an experience neither is, in whole or in part, a
knowledge, nor does it exercise a cognitive function.
Here, however, we may be halted. If there is anything present in
“consciousness” at all, we may be told (at least we constantly are so
told) there must be knowledge of it as present—present, at all
events, in “consciousness.” There is, so it is argued, knowledge at
least of a simple apprehensive type, knowledge of the acquaintance
order, knowledge that, even though not knowledge what. The smell,
it is admitted, does not know about anything else, nor is anything
known about the smell (the same thing, perhaps); but the smell is
known, either by itself, or by the mind, or by some subject, some
unwinking, unremitting eye. No, we must reply; there is no
apprehension without some (however slight) context; no
acquaintance which is not either recognition or expectation.
Acquaintance is presence honored with an escort; presence is
introduced as familiar, or an associate springs up to greet it.
Acquaintance always implies a little friendliness; a trace of re-
knowing, of anticipatory welcome or dread of the trait to follow.
This claim cannot be dismissed as trivial. If valid, it carries with it
the distance between being and knowing: and the recognition of an
element of mediation, that is, of art, in all knowledge. This disparity,
this transcendence, is not something which holds of our knowledge,
of finite knowledge, just marking the gap between our type of
consciousness and some other with which we may contrast it after
the manner of the agnostic or the transcendentalist (who hold so
much property in joint ownership!), but exists because knowing is
knowing, that way of bringing things to bear upon things which we
call reflection—a manipulation of things experienced in the light one
of another.
“Feeling,” I read in a recent article, “feeling is immediately
8
acquainted with its own quality, with its own subjective being.” How
and whence this duplication in the inwards of feeling into feeling the
knower and feeling the known? into feeling as being and feeling as
acquaintance? Let us frankly deny such monsters. Feeling is its own
quality; is its own specific (whence and why, once more, subjective?)
being. If this statement be dogmatism, it is at least worth insistent
declaration, were it only by way of counter-irritant to that other
dogmatism which asserts that being in “consciousness” is always
presence for or in knowledge. So let us repeat once more, that to be
a smell (or anything else) is one thing, to be known as smell,
another; to be a “feeling” one thing, to be known as a “feeling”
9
another. The first is thinghood; existence indubitable, direct; in this
10
way all things are that are in “consciousness” at all. The second is
reflected being, things indicating and calling for other things—
something offering the possibility of truth and hence of falsity. The
first is genuine immediacy; the second is (in the instance discussed)
a pseudo-immediacy, which in the same breath that it proclaims its
immediacy smuggles in another term (and one which is
unexperienced both in itself and in its relation) the subject or
11
“consciousness,” to which the immediate is related.
But we need not remain with dogmatic assertions. To be
acquainted with a thing or with a person has a definite empirical
meaning; we have only to call to mind what it is to be genuinely and
empirically acquainted, to have done forever with this uncanny
presence which, though bare and simple presence, is yet known,
and thus is clothed upon and complicated. To be acquainted with a
thing is to be assured (from the standpoint of the experience itself)
that it is of such and such a character; that it will behave, if given an
opportunity, in such and such a way; that the obviously and
flagrantly present trait is associated with fellow traits that will show
themselves, if the leadings of the present trait are followed out. To
be acquainted is to anticipate to some extent, on the basis of prior
experience. I am, say, barely acquainted with Mr. Smith: then I have
no extended body of associated qualities along with those palpably
present, but at least some one suggested trait occurs; his nose, his
tone of voice, the place where I saw him, his calling in life, an
interesting anecdote about him, etc. To be acquainted is to know
what a thing is like in some particular. If one is acquainted with the
smell of a flower it means that the smell is not just smell, but
reminds one of some other experienced thing which stands in
continuity with the smell. There is thus supplied a condition of
control over or purchase upon what is present, the possibility of
translating it into terms of some other trait not now sensibly present.
Let us return to our example. Let us suppose that S is not just
displaced by K and then by G. Let us suppose it persists; and
persists not as an unchanged S alongside K and G, nor yet as fused
with them into a new further quale J. For in such events, we have
only the type already considered and rejected. For an observer the
new quale might be more complex, or fuller of meaning, than the
original S, K, or G, but might not be experienced as complex. We
might thus suppose a composite photograph which should suggest
nothing of the complexity of its origin and structure. In this case we
should have simply another picture.
But we may also suppose that the blur of the photograph
suggests the superimposition of pictures and something of their
character. Then we get another, and for our problem, much more
fruitful kind of persistence. We will imagine that the final G assumes
this form: Gratification-terminating-movement-induced-by-smell. The
smell is still present; it has persisted. It is not present in its original
form, but is represented with a quality, an office, that of having
excited activity and thereby terminating its career in a certain quale
of gratification. It is not S, but Σ; that is S with an increment of
meaning due to maintenance and fulfilment through a process. S is
no longer just smell, but smell which has excited and thereby
secured.
Here we have a cognitive, but not a cognitional thing. In saying
that the smell is finally experienced as meaning gratification
(through intervening handling, seeing, etc.) and meaning it not in a
hapless way, but in a fashion which operates to effect what is meant,
we retrospectively attribute intellectual force and function to the
smell—and this is what is signified by “cognitive.” Yet the smell is not
cognitional, because it did not knowingly intend to mean this; but is
found, after the event, to have meant it. Nor again is the final
experience, the Σ or transformed S, a knowledge.
Here again the statement may be challenged. Those who agree
with the denial that bare presence of a quale in “consciousness”
constitutes acquaintance and simple apprehension, may now turn
against us, saying that experience of fulfilment of meaning is just
what we mean by knowledge, and this is just what the Σ of our
illustration is. The point is fundamental. As the smell at first was
presence or being, less than knowing, so the fulfilment is an
experience that is more than knowing. Seeing and handling the
flower, enjoying the full meaning of the smell as the odor of just this
beautiful thing, is not knowledge because it is more than knowledge.
As this may seem dogmatic, let us suppose that the fulfilment,
the realization, experience, is a knowledge. Then how shall it be
distinguished from and yet classed with other things called
knowledge, viz., reflective, discursive cognitions? Such knowledges
are what they are precisely because they are not fulfilments, but
intentions, aims, schemes, symbols of overt fulfilment. Knowledge,
perceptual and conceptual, of a hunting dog is prerequisite in order
that I may really hunt with the hounds. The hunting in turn may
increase my knowledge of dogs and their ways. But the knowledge
of the dog, qua knowledge, remains characteristically marked off
from the use of that knowledge in the fulfilment experience, the
hunt. The hunt is a realization of knowledge; it alone, if you please,
verifies, validates, knowledge, or supplies tests of truth. The prior
knowledge of the dog, was, if you wish, hypothetical, lacking in
assurance or categorical certainty. The hunting, the fulfilling,
realizing experience alone gives knowledge, because it alone
completely assures; makes faith good in works.
Now there is and can be no objection to this definition of
knowledge, provided it is consistently adhered to. One has as much
right to identify knowledge with complete assurance, as I have to
identify it with anything else. Considerable justification in the
common use of language, in common sense, may be found for
defining knowledge as complete assurance. But even upon this
definition, the fulfilling experience is not, as such, complete
assurance, and hence not a knowledge. Assurance, cognitive
validation, and guaranteeship, follow from it, but are not coincident
with its occurrence. It gives, but is not, assurance. The concrete
construction of a story, the manipulation of a machine, the hunting
with the dogs, is not, so far as it is fulfilment, a confirmation of
meanings previously entertained as cognitional; that is, is not
contemporaneously experienced as such. To think of prior schemes,
symbols, meanings, as fulfilled in a subsequent experience, is
reflectively to present in their relations to one another both the
meanings and the experiences in which they are, as a matter of fact,
embodied. This reflective attitude cannot be identical with the
fulfilment experience itself; it occurs only in retrospect when the
worth of the meanings, or cognitive ideas, is critically inspected in
the light of their fulfilment; or it occurs as an interruption of the
fulfilling experience. The hunter stops his hunting as a fulfilment to
reflect that he made a mistake in his idea of his dog, or again, that
his dog is everything he thought he was—that his notion of him is
confirmed. Or, the man stops the actual construction of his machine
and turns back upon his plan in correction or in admiring estimate of
its value. The fulfilling experience is not of itself knowledge, then,
even if we identify knowledge with fulness of assurance or
guarantee. Moreover it gives, affords, assurance only in reference to
12
a situation which we have not yet considered.
Before the category of confirmation or refutation can be
introduced, there must be something which means to mean
something and which therefore can be guaranteed or nullified by the
issue—and this is precisely what we have not as yet found. We must
return to our instance and introduce a further complication. Let us
suppose that the smell quale recurs at a later date, and that it recurs
neither as the original S nor yet as the final Σ but as an S’ which is
fated or charged with the sense of the possibility of a fulfilment like
unto Σ. The S’ that recurs is aware of something else which it
means, which it intends to effect through an operation incited by it
and without which its own presence is abortive, and, so to say,
unjustified, senseless. Now we have an experience which is
cognitional, not merely cognitive; which is contemporaneously aware
of meaning something beyond itself, instead of having this meaning
ascribed by another at a later period. The odor knows the rose; the
rose is known by the odor; and the import of each term is
constituted by the relationship in which it stands to the other. That
is, the import of the smell is the indicating and demanding relation
which it sustains to the enjoyment of the rose as its fulfilling
experience; while this enjoyment is just the content or definition of
what the smell consciously meant, i.e., meant to mean. Both the
thing meaning and the thing meant are elements in the same
situation. Both are present, but both are not present in the same
way. In fact, one is present as-not-present-in-the-same-way-in-
which-the-other-is. It is present as something to be rendered
present in the same way through the intervention of an operation.
We must not balk at a purely verbal difficulty. It suggests a verbal
inconsistency to speak of a thing present-as-absent. But all ideal
contents, all aims (that is, things aimed at) are present in just such
fashion. Things can be presented as absent, just as they can be
presented as hard or soft, black or white, six inches or fifty rods
away from the body. The assumption that an ideal content must be
either totally absent, or else present in just the same fashion as it
will be when it is realized, is not only dogmatic, but self-
contradictory. The only way in which an ideal content can be
experienced at all is to be presented as not-present-in-the-same-way
in which something else is present, the latter kind of presence
affording the standard or type of satisfactory presence. When
present in the same way it ceases to be an ideal content. Not a
contrast of bare existence over against non-existence, or of present
consciousness over against reality out of present consciousness, but
of a satisfactory with an unsatisfactory mode of presence makes the
difference between the “really” and the “ideally” present.
In terms of our illustration, handling and enjoying the rose are
present, but they are not present in the same way that the smell is
present. They are present as going to be there in the same way,
through an operation which the smell stands sponsor for. The
situation is inherently an uneasy one—one in which everything
hangs upon the performance of the operation indicated; upon the
adequacy of movement as a connecting link, or real adjustment of
the thing meaning and the thing meant. Generalizing from the
instance, we get the following definition: An experience is a
knowledge, if in its quale there is an experienced distinction and
connection of two elements of the following sort: one means or
intends the presence of the other in the same fashion in which itself
is already present, while the other is that which, while not present in
the same fashion, must become so present if the meaning or
intention of its companion or yoke-fellow is to be fulfilled through
the operation it sets up.

II
We now return briefly to the question of knowledge as
acquaintance, and at greater length to that of knowledge as
assurance, or as fulfilment which confirms and validates. With the
recurrence of the odor as meaning something beyond itself, there is
apprehension, knowledge that. One may now say I know what a
rose smells like; or I know what this smell is like; I am acquainted
with the rose’s agreeable odor. In short, on the basis of a present
quality, the odor anticipates and forestalls some further trait.
We have also the conditions of knowledge of the confirmation
and refutation type. In the working out of the situation just
described, in the transformation, self-indicated and self-demanded,
of the tensional into a harmonious or satisfactory situation, fulfilment
or disappointment results. The odor either does or does not fulfil
itself in the rose. The smell as intention is borne out by the facts, or
is nullified. As has already been pointed out, the subsequent
experience of the fulfilment type is not primarily a confirmation or
refutation. Its import is too vital, too urgent to be reduced in itself
13
just to the value of testing an intention or meaning. But it gets in
reflection just such verificatory significance. If the smell’s intention is
unfulfilled, the discrepancy may throw one back, in reflection, upon
the original situation. Interesting developments then occur. The
smell meant a rose; and yet it did not (so it turns out) mean a rose;
it meant another flower, or something, one can’t just tell what.
Clearly there is something else which enters in; something else
beyond the odor as it was first experienced determined the validity
of its meaning. Here then, perhaps, we have a transcendental, as
distinct from an experimental reference? Only if this something else
makes no difference, or no detectable difference, in the smell itself.
If the utmost observation and reflection can find no difference in the
smell quales that fail and those that succeed in executing their
intentions, then there is an outside controlling and disturbing factor,
which, since it is outside of the situation, can never be utilized in
knowledge, and hence can never be employed in any concrete
testing or verifying. In this case, knowing depends upon an extra-
experimental or transcendental factor. But this very transcendental
quality makes both confirmation and refutation, correction, criticism,
of the pretensions or meanings of things, impossible. For the
conceptions of truth and error, we must, upon the transcendental
basis, substitute those of accidental success or failure. Sometimes
the intention chances upon one, sometimes upon another. Why or
how, the gods only know—and they only if to them the extra-
experimental factor is not extra-experimental, but makes a concrete
difference in the concrete smell. But fortunately the situation is not
one to be thus described. The factor that determines the success or
failure, does institute a difference in the thing which means the
object, and this difference is detectable, once attention, through
failure, has been called to the need of its discovery. At the very
least, it makes this difference: the smell is infected with an element
of uncertainty of meaning—and this as a part of the thing
experienced, not for an observer. This additional awareness at least
brings about an additional wariness. Meaning is more critical, and
operation more cautious.
But we need not stop here. Attention may be fully directed to
the subject of smells. Smells may become the object of knowledge.
14
They may take, pro tempore, the place which the rose formerly
occupied. One may, that is, observe the cases in which odors mean
other things than just roses, may voluntarily produce new cases for
the sake of further inspection, and thus account for the cases where
meanings had been falsified in the issue; discriminate more carefully
the peculiarities of those meanings which the event verified, and
thus safeguard and bulwark to some extent the employing of similar
meanings in the future. Superficially, it may then seem as if odors
were treated after the fashion of Locke’s simple ideas, or Hume’s
“distinct ideas which are separate existences.” Smells apparently
assume an independent, isolated status during this period of
investigation. “Sensations,” as the laboratory psychologist and the
analytic psychologist generally studies them, are examples of just
such detached things. But egregious error results if we forget that
this seeming isolation and detachment is the outcome of a deliberate
scientific device—that it is simply a part of the scientific technique of
an inquiry directed upon securing tested conclusions. Just and only
because odors (or any group of qualities) are parts of a connected
world are they signs of things beyond themselves; and only because
they are signs is it profitable and necessary to study them as if they
were complete, self-enclosed entities.
In the reflective determination of things with reference to their
specifically meaning other things, experiences of fulfilment,
disappointment, and going astray inevitably play an important and
recurrent rôle. They also are realistic facts, related in realistic ways
to the things that intend to mean other things and to the things
intended. When these fulfilments and refusals are reflected upon in
the determinate relations in which they stand to their relevant
meanings, they obtain a quality which is quite lacking to them in
their immediate occurrence as just fulfilments or disappointments;
viz., the property of affording assurance and correction—of
confirming and refuting. Truth and falsity are not properties of any
experience or thing, in and of itself or in its first intention; but of
things where the problem of assurance consciously enters in. Truth
and falsity present themselves as significant facts only in situations
in which specific meanings and their already experienced fulfilments
and non-fulfilments are intentionally compared and contrasted with
reference to the question of the worth, as to reliability of meaning,
of the given meaning or class of meanings. Like knowledge itself,
truth is an experienced relation of things, and it has no meaning
15
outside of such relation, any more than such adjectives as
comfortable applied to a lodging, correct applied to speech,
persuasive applied to an orator, etc., have worth apart from the
specific things to which they are applied. It would be a great gain for
logic and epistemology, if we were always to translate the noun
“truth” back into the adjective “true,” and this back into the adverb
“truly”; at least, if we were to do so until we have familiarized
ourselves thoroughly with the fact that “truth” is an abstract noun,
summarizing a quality presented by specific affairs in their own
specific contents.
III
I have attempted, in the foregoing pages, a description of the
function of knowledge in its own terms and on its merits—a
description which in intention is realistic, if by realistic we are
content to mean naturalistic, a description undertaken on the basis
of what Mr. Santayana has well called “following the lead of the
subject-matter.” Unfortunately at the present time all such
undertakings contend with a serious extraneous obstacle.
Accomplishing the undertaking has difficulties enough of its own to
reckon with; and first attempts are sure to be imperfect, if not
radically wrong. But at present the attempts are not, for the most
part, even listened to on their own account, they are not examined
and criticised as naturalistic attempts. They are compared with
undertakings of a wholly different nature, with an epistemological
theory of knowledge, and the assumptions of this extraneous theory
are taken as a ready-made standard by which to test their validity.
Literally of course, “epistemology” means only theory of knowledge;
the term might therefore have been employed simply as a synonym
for a descriptive logic; for a theory that takes knowledge as it finds it
and attempts to give the same kind of an account of it that would be
given of any other natural function or occurrence. But the mere
mention of what might have been only accentuates what is. The
things that pass for epistemology all assume that knowledge is not a
natural function or event, but a mystery.
Epistemology starts from the assumption that certain conditions
lie back of knowledge. The mystery would be great enough if
knowledge were constituted by non-natural conditions back of
knowledge, but the mystery is increased by the fact that the
conditions are defined so as to be incompatible with knowledge.
Hence the primary problem of epistemology is: How is knowledge
überhaupt, knowledge at large, possible? Because of the
incompatibility between the concrete occurrence and function of
knowledge and the conditions back of it to which it must conform, a
second problem arises: How is knowledge in general, knowledge
überhaupt, valid? Hence the complete divorce in contemporary
thought between epistemology as theory of knowledge and logic as
an account of the specific ways in which particular beliefs that are
better than other alternative beliefs regarding the same matters are
formed; and also the complete divorce between a naturalistic, a
biological and social psychology, setting forth how the function of
knowledge is evolved out of other natural activities, and
epistemology as an account of how knowledge is possible anyhow.
It is out of the question to set forth in this place in detail the
contrast between transcendental epistemology and an experimental
theory of knowledge. It may assist the understanding of the latter,
however, if I point out, baldly and briefly, how, out of the
distinctively empirical situation, there arise those assumptions which
make knowledge a mystery, and hence a topic for a peculiar branch
of philosophizing.
As just pointed out, epistemology makes the possibility of
knowledge a problem, because it assumes back of knowledge
conditions incompatible with the obvious traits of knowledge as it
empirically exists. These assumptions are that the organ or
instrument of knowledge is not a natural object, but some ready-
made state of mind or consciousness, something purely “subjective,”
a peculiar kind of existence which lives, moves, and has its being in
a realm different from things to be known; and that the ultimate
goal and content of knowledge is a fixed, ready-made thing which
has no organic connections with the origin, purpose, and growth of
the attempt to know it, some kind of Ding-an-sich or absolute, extra-
empirical “Reality.”
(1) It is not difficult to see at what point in the development of
natural knowledge, or the signifying of one thing by another, there
arises the notion of the knowing medium as something radically
different in the order of existence from the thing to be known. It
arises subsequent to the repeated experience of non-fulfilment, of
frustration and disappointment. The odor did not after all mean the
rose; it meant something quite different; and yet its indicative
function was exercised so forcibly that we could not help—or at least
did not help—believing in the existence of the rose. This is a familiar
and typical kind of experience, one which very early leads to the
recognition that “things are not what they seem.” There are two
contrasted methods of dealing with this recognition: one is the
method indicated above (p. 93). We go more thoroughly, patiently,
and carefully into the facts of the case. We employ all sorts of
methods, invented for the purpose, of examining the things that are
signs and the things that are signified, and we experimentally
produce various situations, in order that we may tell what smells
mean roses when roses are meant, what it is about the smell and
the rose that led us into error; and that we may be able to
discriminate those cases in which a suspended conclusion is all that
circumstances admit. We simply do the best we can to regulate our
system of signs so that they become as instructive as possible,
utilizing for this purpose (as indicated above) all possible
experiences of success and of failure, and deliberately instituting
cases which will throw light on the specific empirical causes of
success and failure.
Now it so happens that when the facts of error were consciously
generalized and formulated, namely in Greek thought, such a
technique of specific inquiry and rectification did not exist—in fact, it
hardly could come into existence until after error had been seized
upon as constituting a fundamental anomaly. Hence the method just
outlined of dealing with the situation was impossible. We can
imagine disconsolate ghosts willing to postpone any professed
solution of the difficulty till subsequent generations have thrown
more light on the question itself; we can hardly imagine passionate
human beings exercising such reserve. At all events, Greek thought
provided what seemed a satisfactory way out: there are two orders
of existence, one permanent and complete, the noumenal region, to
which alone the characteristic of Being is properly applicable, the
other transitory, phenomenal, sensible, a region of non-Being, or at
least of mere Coming-to-be, a region in which Being is hopelessly
mixed with non-Being, with the unreal. The former alone is the
domain of knowledge, of truth; the latter is the territory of opinion,
confusion, and error. In short, the contrast within experience of the
cases in which things successfully and unsuccessfully maintained and
executed the meanings of other things was erected into a wholesale
difference of status in the intrinsic characters of the things involved
in the two types of cases.
With the beginnings of modern thought, the region of the
“unreal,” the source of opinion and error, was located exclusively in
the individual. The object was all real and all satisfactory, but the
“subject” could approach the object only through his own subjective
states, his “sensations” and “ideas.” The Greek conception of two
orders of existence was retained, but instead of the two orders
characterizing the “universe” itself, one was the universe, the other
was the individual mind trying to know that universe. This scheme
would obviously easily account for error and hallucination; but how
could knowledge, truth, ever come about such a basis? The Greek
problem of the possibility of error became the modern problem of
the possibility of knowledge.
Putting the matter in terms that are independent of history,
experiences of failure, disappointment, non-fulfilment of the function
of meaning and contention may lead the individual to the path of
science—to more careful and extensive investigation of the things
themselves, with a view to detecting specific sources of error, and
guarding against them, and regulating, so far as possible, the
conditions under which objects are bearers of meanings beyond
themselves. But impatient of such slow and tentative methods
(which insure not infallibility but increased probability of valid
conclusions), by reason of disappointment a person may turn
epistemologist. He may then take the discrepancy, the failure of the
smell to execute its own intended meaning, as a wholesale, rather
than as a specific fact: as evidence of a contrast in general between
things meaning and things meant, instead of as evidence of the
need of a more cautious and thorough inspection of odors and
execution of operations indicated by them. One may then say: Woe
is me; smells are only my smells, subjective states existing in an
order of being made out of consciousness, while roses exist in
another order made out of a radically different sort of stuff; or, odors
are made out of “finite” consciousness as their stuff, while the real
things, the objects which fulfil them, are made out of an “infinite”
consciousness as their material. Hence some purely metaphysical tie
has to be called in to bring them into connection with each other.
And yet this tie does not concern knowledge; it does not make the
meaning of one odor any more correct than that of another, nor
enable us to discriminate relative degrees of correctness. As a
principle of control, this transcendental connection is related to all
16
alike, and hence condemns and justifies all alike.
It is interesting to note that the transcendentalist almost
invariably first falls into the psychological fallacy; and then having
himself taken the psychologist’s attitude (the attitude which is
interested in meanings as themselves self-inclosed “ideas”) accuses
the empiricist whom he criticises of having confused mere
psychological existence with logical validity. That is, he begins by
supposing that the smell of our illustration (and all the cognitional
objects for which this is used as a symbol) is a purely mental or
psychical state, so that the question of logical reference or intention
is the problem of how the merely mental can “know” the extra-
mental. But from a strictly empirical point of view, the smell which
knows is no more merely mental than is the rose known. We may, if
we please, say that the smell when involving conscious meaning or
intention is “mental,” but this term “mental” does not denote some
separate type of existence—existence as a state of consciousness. It
denotes only the fact that the smell, a real and non-psychical object,
now exercises an intellectual function. This new property involves, as
James has pointed out, an additive relation—a new property
possessed by a non-mental object, when that object, occurring in a
17
new context, assumes a further office and use. To be “in the mind”
means to be in a situation in which the function of intending is
18
directly concerned. Will not some one who believes that the
knowing experience is ab origine a strictly “mental” thing, explain
how, as matter of fact, it does get a specific, extra-mental reference,
capable of being tested, confirmed, or refuted? Or, if he believes that
viewing it as merely mental expresses only the form it takes for
psychological analysis, will he not explain why he so persistently
attributes the inherently “mental” characterization of it to the
empiricist whom he criticises? An object becomes meaning when
used empirically in a certain way; and, under certain circumstances,
the exact character and worth of this meaning becomes an object of
solicitude. But the transcendental epistemologist with his purely
psychical “meanings” and his purely extra-empirical “truths” assumes
a Deus ex Machina whose mechanism is preserved a secret. And as
if to add to the arbitrary character of his assumption, he has to
admit that the transcendental a priori faculty by which mental states
get objective reference does not in the least help us to discriminate,
in the concrete, between an objective reference that is false and one
that is valid.
(2) The counterpart assumption to that of pure aboriginal
“mental states” is, of course, that of an Absolute Reality, fixed and
complete in itself, of which our “mental states” are bare transitory
hints, their true meaning and their transcendent goal being the Truth
in rerum natura. If the organ and medium of knowing is a self-
inclosed order of existence different in kind from the Object to be
known, then that Object must stand out there in complete aloofness
from the concrete purpose and procedure of knowing it. But if we go
back to the knowing as a natural occurrence, capable of description,
we find that just as a smell does not mean Rose in general (or
anything else at large), but means a specific group of qualities
whose experience is intended and anticipated, so the function of
knowing is always expressed in connections between a given
experience and a specific possible wanted experience. The “rose”
that is meant in a particular situation is the rose of that situation.
When this experience is consummated, it is achieved as the
fulfilment of the conditions in which just that intention was
entertained—not as the fulfilment of a faculty of knowledge or a
meaning in general. Subsequent meanings and subsequent
fulfilments may increase, may enrich the consummating experience;
the object or content of the rose as known may be other and fuller
next time and so on. But we have no right to set up “a rose” at large
or in general as the object of the knowing odor; the object of a
knowledge is always strictly correlative to that particular thing which
means it. It is not something which can be put in a wholesale way
over against that which cognitively refers to it, as when the
epistemologist puts the “real” rose (object) over against a merely
phenomenal or empirical rose which this smell happens to mean. As
the meaning gets more complex, fuller, more finely discriminated,
the object which realizes or fulfils the meaning grows similarly in
quality. But we cannot set up a rose, an object of fullest, complete,
and exhaustive content as that which is really meant by any and
every odor of a rose, whether it consciously meant to mean it or not.
The test of the cognitional rectitude of the odor lies in the specific
object which it sets out to secure. This is the meaning of the
statement that the import of each term is found in its relationship to
the other. It applies to object meant as well as to the meaning.
Fulfilment, completion are always relative terms. Hence the criterion
of the truth or falsity of the meaning, of the adequacy, of the
cognitional thing lies within the relationships of the situation and not
without. The thing that means another by means of an intervening
operation either succeeds or fails in accomplishing the operation
indicated, while this operation either gives or fails to give the object
meant. Hence the truth or falsity of the original cognitional object.

IV
From this excursion, I return in conclusion to a brief general
characterization of those situations in which we are aware that
things mean other things and are so critically aware of it that, in
order to increase the probability of fulfilment and to decrease the
chance of frustration, all possible pains are taken to regulate the

You might also like