Arduino Electronics Blueprints - Sample Chapter
Arduino Electronics Blueprints - Sample Chapter
ee
Sa
pl
e
electrical engineer with 26 years of experience. He has authored several books on Lego
Robotics and Arduinos. His latest book published by Maker Media, titled Make: Basic
Arduino Projects, has been approved by the Alabama State Department of Education
to be on their reading list. He's also a Certified Electronics Technician (CETa) and
Exam Administrator (CA) with ETA International as well as State Certified Teacher
for Career Technical Education (CTE) as a Level 2 Specialist in electronics technology.
He has worked on industrial robotic systems, automotive electronic modules/systems,
and embedded wireless controls for small consumer appliances. While at the Chrysler
Corporation, Don developed a weekend enrichment pre-engineering program for
inner city kids. He's a contributing writer and webinar lecturer for Design News
Magazine. He is also an electronics and robotics technologist who has developed
21st century educational products and training materials for Makers, hardware
start-up entrepreneurs, and educators.
Preface
You have purchased your first Arduino, and now you're wondering what project
to build with it. There are hundreds of websites with an assortment of electronic
gadgets and devices to build, but the search and choosing the first project can be
overwhelming. Besides building awesome Arduino gadgets, some of the website
projects leave out how the electronics and code work with a programmable
prototyping platform. Also, the projects found on the Web don't provide additional
challenges to test your new Maker skills as well.
The Arduino Electronics Blueprints book was written to address the concerns mentioned
in a user friendly and educational format. Every chapter in the book starts off with
either a historical reference to electronic discoveries or a brief discussion of present
technologies used in contemporary consumer, entertainment, or industrial products.
The book was designed to show how to build awesome electronic devices using
parts found in laboratory bins or junk boxes. Also, new prototyping materials such as
littleBits electronic modules and Elenco SNAP circuit kits are introduced to readers as
well. The new and exciting prototyping materials presented allow us to rapidly build
the target Arduino device discussed in some of the book's chapters. To aid readers in
building the fun Arduino projects, a Parts list of electronic components is included in
each chapter of the book. Detailed circuit schematic and wiring diagrams and Arduino
code are provided in each chapter. Also, basic circuit theory and Arduino code
explanations are provided in each project chapter as well. To conclude the chapter,
a DIY challenge is presented, so readers may explore additional prototyping topics
in new product designs of their own. I enjoyed designing, building, and testing each
chapter's project and hope readers of the Arduino Electronics Blueprints book will find
the projects to be fun and entertaining as well.
Preface
Preface
Chapter 10, Arduino Scrolling Marquee, discusses organic light-emitting diode (OLED)
technology by building an Arduino-based scrolling marquee. Also, the reader will
learn to use any ordinary IR handheld remote to control the scrolling effect of the
OLED marquee.
[ 55 ]
In this chapter, we will learn how to build a talking logic probe for testing digital
circuits and devices. Also, to make the logic probe unique from the typical off-the-shelf
testers, voice synthesis will be used to speak the operating conditions of digital circuits.
An EMIC 2 text-to-speech (TTS) module will be used to generate the voice synthesis
for the logic probe. Specific EMIC 2 TTS module operation modes will be explored
in this chapter using different Arduino sketches. This chapter will also provide
instructions for building the logic probe.
Parts list
The following is the list of parts required for building a talking logic probe:
1 kilo ohm resistor (black, brown, red, and gold) (one unit)
Breadboard
Wires
[ 56 ]
Chapter 3
The talking logic probe block diagram is an engineering development tool used to
convey a complete product design using simple graphics. The block diagram also
makes it easier to plan the breadboard for prototyping and testing of the talking logic
probe in a maker's workshop or laboratory bench. A final observation of the talking
logic probe block diagram is that the basic computer convention of inputs is on the
left-hand side, the processor is located in the middle, and the outputs are placed on
the right-hand side of the design layout. As shown, the Digital Circuit under Test
(DCuT) is on the left-hand side, the Arduino is located in the middle, and the EMIC
2 TTS module with the 8 ohm speaker is shown on the right-hand side of the block
diagram. The DCuT will provide binary high or low signals, based on the digital
circuits inputs being triggered.
[ 57 ]
This left to right design method makes it easier to build the talking logic probe and
troubleshoot the errors during the testing phase of the project.
[ 58 ]
Chapter 3
Another method of parts placement onto the solderless breadboard is to use the
block diagram shown previously. This method of parts arrangement, illustrated in
the block diagram, allows ease in testing each subcircuit separately. For example,
the EMIC 2 TTS module can be tested by using a sample code given next. With the
sketch uploaded to the Arduino, the musical song Daisy Bell can be heard through
the speaker. After the song has played once, pressing the reset button repeats the
musical lyrics:
/*
Emic 2 Text-to-Speech Module: Basic Demonstration
Author: Joe Grand [www.grandideastudio.com]
Contact: support@parallax.com
[ 59 ]
10
11
13
[ 60 ]
Chapter 3
/*
When the Emic 2 powers on, it takes about 3 seconds for it to
successfully
initialize. It then sends a ":" character to indicate it's
ready to accept
commands. If the Emic 2 is already initialized, a CR will also
cause it
to send a ":"
*/
emicSerial.print('\n');
// Send a CR in case the
system is already up
while (emicSerial.read() != ':');
// When the Emic 2 has
initialized and is ready, it will send a single ':' character,
so wait here until we receive it
delay(10);
// Short delay
emicSerial.flush();
// Flush the receive buffer
}
void loop() // Main code, to run repeatedly
{
// Speak some text
emicSerial.print('S');
emicSerial.print("Hello. My name is the Emic 2 Text-to-Speech
module. I would like to sing you a song."); // Send the desired
string to convert to speech
emicSerial.print('\n');
digitalWrite(ledPin, HIGH);
// Turn on LED while Emic is
outputting audio
while (emicSerial.read() != ':');
// Wait here until the Emic
2 responds with a ":" indicating it's ready to accept the next
command
digitalWrite(ledPin, LOW);
delay(500);
// Sing a song
emicSerial.print("D1\n");
digitalWrite(ledPin, HIGH);
// Turn on LED while Emic is
outputting audio
while (emicSerial.read() != ':');
// Wait here until the Emic
2 responds with a ":" indicating it's ready to accept the next
command
digitalWrite(ledPin, LOW);
[ 61 ]
In addition to the test sketch, the circuit schematic diagram for the solderless
breadboard wiring diagram is shown for reference:
[ 62 ]
Chapter 3
[ 63 ]
Another thing to note about the EMIC 2 is the small audio jack soldered onto
the PCB. This standard audio jack (size 1/8" or 3.5 mm) allows the device to be
connected to most audio Hi-Fi systems or headphones, if desired. An example
design application for this audio jack is the creation of a portable foreign language
training tool. Connection to headphones instead could provide individual training
to the foreign language learner without disturbing people in the room. The EMIC 2
TTS module has two speech synthesis languages available for English and Spanish.
Another training aid application suitable for the audio jack feature is a physical
digital logic simulator with audible I/O feedback. The audio jack could also be used
in this project instead of the speaker.
If both 3.5 mm jack and external 8 ohm speaker are used at
the same time, audio quality might be affected.
[ 64 ]
Chapter 3
Electrical connections
As seen previously, there are only six electrical connections or pins required for
wiring the EMIC 2 TTS module to an Arduino. The electrical connections consist
of GND, 5 V, SOUT, SIN, SP-, and SP+. The following descriptions explain the
operation of these six electrical connections:
Pin 1:GND: This is a device ground pin. Connect the Arduino's supply
voltage ground (GND) to this pin.
Pin 2: 5 V: This is a device power pin. Connect the Arduino's positive voltage
(5 V) to this pin.
Pin 4: SIN: This pin is a device serial input from the Arduino. It is a 3.3 V to 5
V TTL level interface, 9,600 bps, 8 data bits, no parity, 1 stop bit, non-inverted
digital signal.
The following circuit schematic diagram illustrates this wiring connection scheme:
[ 65 ]
2. Upload the talking logic probe code to the Arduino using the sketch given
after the schematic diagram.
3. The phrase Signal is Low will be heard through the talking logic
probe's speaker.
4. Touch the logic probe's green test lead onto the EMIC 2 TTS
module's +5 V pin.
[ 66 ]
Chapter 3
5. The phrase Signal is High will be heard through the talking logic
probe's speaker.
The code required to make the talking logic probe operational is:
/*
Talking Logic Probe
Author: Don Wilcher 2014 14 11
Program Description:
This program allows tracing digital circuit signals using the
Emic 2 Text-to-Speech
[ 67 ]
10
11
[ 68 ]
Chapter 3
while (emicSerial.read() != ':');
// Wait here until the
Emic 2 responds with a ":" indicating it's ready to accept the
next command
}
else{
emicSerial.print("SIGNAL IS LOW"); // Emic 2 will speak LOW
message if status value is false
emicSerial.print('\n');
while (emicSerial.read() != ':');
// Wait here until the
Emic 2 responds with a ":" indicating it's ready to accept the
next command
delay(1000);
//
1 second delay
}
}
As the talking logic probe toggles between two phrases, based on the detected
input signals, occasionally, a text phrase can be out of sync. For example, the
SIGNAL IS HIGH phrase may be heard through the speaker with no +5 V DC input
signal detected by the Arduino. This unstable condition occurs when a digital or
microcontroller's assigned pin isn't properly terminated. Electronic circuits such as
a microcontroller's external crystal oscillator can produce radiated switching signals
capable of disrupting its operating embedded code. The unstable speech heard
through the speaker is, again, produced by the crystal oscillator's radiated switching
signal. Removing this electrical noise consists of providing a signal path to ground
using a pull-down resistor. Adding a 1 kilo ohm resistor between the Arduino's D5
pin to ground will provide a stable speech output for the talking logic probe. The
solderless breadboard wiring diagram and circuit schematic diagram show a 1 kilo
ohm resistor added to the Arduino's D5 pin.
[ 69 ]
For reference, the following is the talking logic probe circuit schematic diagram:
Another feature that can be added to the talking logic probe is a momentary
pushbutton electrical switch for activating the detection function. With the test lead
attached to the digital circuit's specific I/O pin, a press of the momentary pushbutton
switch will provide a quick go-no-go check of the device's electrical operation. To
include this manual signal detection feature requires the momentary pushbutton
switch to be wired between the logic probe's test lead and the Arduino's D5 pin.
[ 70 ]
Chapter 3
This wiring connection is also known as a series circuit. The following is the
solderless breadboard wiring diagram for adding the momentary pushbutton
electrical switch:
[ 71 ]
The following is the talking logic probe with a switch detection feature circuit
schematic diagram:
Removing this library (header file) from the sketch will cause compilation errors
throughout the code, and not allow the Arduino to correctly operate the EMIC 2 TTS
module. The pins needed to send digital data between the Arduino and the EMIC 2
TTS module are:
#define rxPin
pin)
#define txPin
pin)
10
11
[ 72 ]
Chapter 3
The traditional serial communication pins on the Arduino are D0 and D1. These
digital pins may be used in the talking logic probe sketch, but must be removed
while uploading the sketch. The reason is because the physical link between the
Arduino and the EMIC 2 TTS module while uploading a sketch requires using pins
D0 and D1. There is an electrical conflict in establishing communications between
the desktop PC or notebook computer and the EMIC 2 using the true tx:D0 and rx:D1
pins of the Arduino. To illustrate this electrical communication conflict, change the rx
and tx pins to D0 and D1 on the Arduino. Upload the modified sketch to the Arduino
and notice the following error displayed on the IDE's message window:
To troubleshoot this problem, remove the two wires connected to the Arduino tx and
rx pins while uploading. The wires can be reconnected to these pins after the sketch
has been uploaded to the Arduino.
The next two lines of code to examine are as follows:
#define probein 5 // Digital probe input
int probe=0; // probein variable status
The talking probe test lead is connected to pin D5 of the Arduino. The digital signals
are received using this pin. The int probe = 0 status variable will be used to collect
the test lead's digital signals during circuit testing. With the test lead pin defined
with its signal status variable, the declared Arduino pins operating modes will be set
up using the following lines of code:
// define pin modes
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
pinMode(probein, INPUT);
[ 73 ]
The void setup() function is used to establish the I/O modes for the declared
Arduino pins. The next few lines of code help establish the communication protocol
(rules) between the Arduino and EMIC 2 TTS module:
// set the data rate for the SoftwareSerial port
emicSerial.begin(9600);
emicSerial.print('\n');
// Send a CR in case the
system is already up
while (emicSerial.read() != ':');
// When the Emic 2 has
initialized and is ready, it will send a single ':' character,
so wait here until we receive it
delay(10);
// Short delay
emicSerial.flush();
// Flush the receive buffer
The preceding lines of code are required when using the EMIC 2 TTS module for
different voice/speech synthesis projects. For creating the talking logic probe sketch,
a few lines of code were taken from the EMIC 2 sample sketch from the Parallax Inc
website. Code reuse, as illustrated here, saves time in developing Arduino sketches
and allows the maker to focus on building the electronics instead of debugging
software.
The main void main ()code allows the Arduino to read the digital signal
detected and speak the voltage level phrases. The first line of code enables the
EMIC 2 for speech:
// Speak some text
emicSerial.print('S');
With the text-to-speech module ready to speak, the test lead's status can be read
using probein, and stored in the variable int probe:
probe=digitalRead(probein);// read probein status
Once the signal level has been stored in the status variable probe, determining
which message to speak is based on this conditional statement:
if(probe == HIGH){
status value is true
[ 74 ]
Chapter 3
If the statement is true, the EMIC 2 TTS module will speak the phrase SIGNAL IS
HIGH using the following line of code:
emicSerial.print("SIGNAL IS HIGH");
string to convert to speech
Once this text is converting into speech by the EMIC 2, a carriage return is needed to
speak the next line of text:
micSerial.print('\n');
The next message phrase for speech conversion when the signal detected by the test
lead is low is SIGNAL IS LOW. The else keyword completes the conditional statement
instruction of the Arduino code given here:
else{
emicSerial.print("SIGNAL IS LOW"); // Emic 2 will speak
LOW message if status value is false
The two processes of waiting on the next phrase message for conversion and
establishing handshaking, as previously discussed, are as follows:
emicSerial.print("SIGNAL IS LOW"); // Emic 2 will speak LOW
message if status value is false
emicSerial.print('\n');
while (emicSerial.read() != ':');
// Wait here until the Emic
2 responds with a ":" indicating it's ready to accept the next
command
[ 75 ]
The delay (1000) instruction allows the two phrases to repeat every one second,
as shown in the last line of Arduino code. The following flowchart graphically
summarizes the talking logic probe sketch. The structure of this flowchart can serve
as a template when developing EMIC 2 applications. The final section of the chapter
will end with a discussion on DecTalk speech synthesizer engine. Code examples of
how to set various feature/functions of the EMIC 2 TTS module will be provided for
further hands-on exploration.
[ 76 ]
Chapter 3
[ 77 ]
[ 78 ]
Chapter 3
With this audio power amplifier IC and the DecTalk volume command, there
is no need to add an amplifier circuit to the EMIC 2 TTS module to obtain a
suitable output level.
Nx: This selects an EMIC 2 speaking voice. There are nine voices to choose
from as listed here:
1. Perfect Paul (Paulo)
2. Huge Harry (Francisco)
3. Beautiful Betty
4. Uppity Ursula
5. Doctor Dennis (Enrique)
6. Kit the Kid
7. Frail Frank
8. Rough Rita
9. Whispering Wendy (Beatriz)
The EMIC 2 TTS module's voice can be changed using the following Arduino
code:
// Set voice
emicSerial.print("N1\n");
while (emicSerial.read() != ':');
character
After uploading the modified talking logic probe sketch with the DecTalk set
voice command, Huge Harry (Francisco) will be heard through the speaker.
Wx: This sets Set the EMIC 2 TTS module's speaking rate (words per minute).
Depending on the application, the speaking rate may need to be adjusted
for clarity and understanding of the message. The range of values that are
accepted by the EMIC 2 is 75 (slowest) to 600 (fastest). The default speaking
rate value is set to 200. The following is the example Arduino code to set the
EMIC 2 TTS module's rate:
// Set speaking rate
emicSerial.print("W100\n");
while (emicSerial.read() != ':');
character
[ 79 ]
After uploading the modified sketch, the talking logic probe will speak the
two phrases in Latin American Spanish.
Summary
In this chapter, a discussion on the theory and operation of a talking logic probe
was covered. A basic talking logic probe design was shown along with assembly
and testing instructions for building the speech synthesis electrical tester. Finally,
technical details of how the EMIC 2 text-to-speech module operates were discussed
using a series of hands-on experiments. The experiments showed how to set specific
EMIC 2 DecTalk speech synthesizer engine feature/functions using Arduino code
programming techniques.
In the next chapter, a hands-on investigation on using a web page as a Human
Machine Interface (HMI) controller will be illustrated. As in the previous chapters,
a series of lab experiments, followed by a final project will show how to build an
Arduino-based HMI controller.
[ 80 ]
www.PacktPub.com
Stay Connected: