Abstract
Knowledge of binary and hexadecimal numerical representations and conversions
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsAuthor information
Authors and Affiliations
Appendices
Summary
Problems
2.1 15.1 Architecture of Microcontrollers
Problem 15.1
-
A.
List some common IO devices.
-
B.
Draw the schematic of a CPU.
-
C.
Draw the schematic of a basic computer.
Problem 15.2
Convert the following numbers to bits:
-
A.
14 GB
-
B.
27 MB
-
C.
42 KB
-
D.
0.97 TB
Problem 15.3
-
A.
Draw a diagram showing a CPU communicating with memory over a 16-bit bus and label each of the data connections.
-
B.
Repeat the previous task but use the abbreviated bus notation.
2.2 15.2 Memory
Problem 15.4
Store the value 57984 (decimal) in memory starting at address 0100h using little-endian notation. Repeat with big-endian notation. Present the corresponding tables.
Problem 15.5
Store the value 372110 in memory starting at address 0400h using little-endian notation. Repeat with big-endian notation. Present the corresponding tables.
Problem 15.6
What is the decimal value stored in memory in the following table starting from address 0200h using little-endian notation? Repeat with big-endian notation.
Address | Byte value |
---|---|
0204h | … |
0203h | 01h |
0202h | 22h |
0201h | FFh |
0200h | A0h |
01FFh | .... |
Problem 15.7
What is the decimal value stored in memory in the following table starting from address 0200h using little-endian notation? Repeat with big-endian notation.
Address | Byte value |
---|---|
0204h | … |
0203h | 77h |
0202h | 04h |
0201h | BBh |
0200h | 08h |
01FFh | .... |
Problem 15.8
Describe each of the following types of memory and their application:
-
A.
RAM
-
B.
ROM
-
C.
EEPROM
-
D.
PROM
-
E.
EPROM
-
F.
Flash
Problem 15.9
-
A.
Describe the difference between volatile and nonvolatile memory.
-
B.
Describe the advantages and disadvantages of flash memory.
Problem 15.10
How wide must a data bus be to access:
-
A.
1 GB of memory?
-
B.
1.44 MB of memory?
-
C.
1 TB of memory?
-
D.
22 KB of memory?
2.3 15.3 Arduino Uno: An Embedded Microcontroller
Problem 15.11
-
A.
Write the bare-bones minimum that is required to create an Arduino sketch.
-
B.
Write the corresponding C code.
Problem 15.12
What type of memory and how much of it is available for programs on the Arduino Uno?
Problem 15.13
Describe the process of writing and uploading a program for the Arduino.
2.4 15.4 Basic Arduino Syntax
Problem 15.14
Describe the rationale behind a function header and write an example for a function that accepts several integers and returns the maximum. Do not worry about implementation of the function.
Problem 15.15
Design a function that will return the integer value of a character that is passed to the function (Hint: use typecasting).
Problem 15.16
Write a function for the Arduino that takes in the resistance and current in a circuit branch and finds and returns the voltage drop across the resistance.
Problem 15.17
Write a function for the Arduino that takes in the value of two resistors and finds the equivalent parallel combination of the two (returned as a double).
Problem 15.18
Write a function for the Arduino that returns the value of the transfer function for a given frequency for the following low-pass filter with R = 100 kΩ and C = 1.59 nF. Present the corresponding code.
Problem 15.19
Write a function that will configure the pins in the following configuration. Also if needed enable the pull up resistors on any input pins:
Pin 2 = INPUT
Pin 3 = OUTPUT
Pin 4 = OUTPUT
Pin 5 = INPUT
Pin 6 = INPUT
Pin 7 = OUTPUT
Pin A0 = INPUT
Pin A2 = OUTPUT
Problem 15.20
Design and implement a code that reads in an analog voltage value across a variable resistor (potentiometer) and converts the resulting value into the duty cycle value of a square wave on pin 3. The potentiometer should be on pin A4. Discuss the corresponding normalization procedure.
Problem 15.21
Write a program that reads in an analog voltage value from a light sensor (phototransistor) on analog pin A0 and converts this value to the corresponding binary number to be displayed on 8 LEDs. Discuss the corresponding normalization procedure.
Problem 15.22
If the output of analogWrite is a duty cycle ranging from 5 to 95 % corresponding to 0–255, convert the following values to their complement:
-
A.
67 %
-
B.
23
-
C.
44 %
-
D.
233
Problem 15.23
The ADC on the Arduino takes in an input signal in the range of 0–5 V and converts it to a decimal value in the range of 0–1023. Convert the following values to their complements:
-
A.
3.7 V
-
B.
898
-
C.
1.2 V
-
D.
469
Problem 15.24
Write a program that counts in binary from 0 to 255 on eight external LEDs on pins 4–11 (the binary counter). Use appropriate resistors to limit the current.
Problem 15.25
Create a program and external circuitry that mimics a traffic light. The “green” stays active for 8 s. The “yellow” is active for 3 s and then “red” is active for 10 s. The pattern repeats indefinitely.
Problem 15.26
Create a program that turns the Arduino into a handheld flashlight using a push button to turn an LED on when the button is held down.
Problem 15.27
-
A.
Write a program to control the speed of a motor using external circuitry (a single switching transistor or an H-bridge), a potentiometer, and the servo library.
-
B.
Realize the corresponding project in hardware.
Problem 15.28
Write a program to control the position of a servo using ten switches attached to digital pins 2 and 4–12. The servo should be attached to pin 4. Each switch is acting as one bit of the 10-bit ADC of the Arduino.
2.5 15.5 More Advanced Arduino Programming
Problem 15.29
Implement the following digital logic circuit in a function that sets the output pin (pin 10 of the Arduino) HIGH or LOW.
Problem 15.30
Repeat the previous problem for the circuit shown in the following figure.
Problem 15.31
Repeat problem 15.29 for the circuit shown in the following figure.
Problem 15.32
Implement a function that sets an output pin (pin 10) HIGH or LOW as shown in the following figure (use a switch statement).
Problem 15.33
Translate the code from Example 15.9 in Section 15.5.2 to use conditional statements instead of the switch statement.
Problem 15.34
What is an infinite loop? Discuss and document several ways that an infinite loop can occur and how to ensure this does not happen.
Problem 15.35
Translate the following while loops into for loops:
Problem 15.36
Translate the following for loops into while loops:
Problem 15.37
Find and fix the errors in the following loops:
Problem 15.38
Write a function that will cycle through the string “Elizabeth” and will copy the string into a blank string that has ten entries (remember the terminating null character at the end of the string).
Problem 15.39
Write a sketch that will print “An Arduino says Hello world!” to the serial monitor the following number of times:
-
A.
7
-
B.
12
-
C.
190
Problem 15.40
Write a sketch that can print out the binary representation of the numbers 0–64 to the serial monitor. Hint: Use a function to convert the number to binary then print it out.
Problem 15.41
Write a function that will cycle through an array and print the values with the corresponding indices to the serial monitor. The array should be {7, 29, 444, 42, 69, 8, −10020}.
Problem 15.42
Design a program that uses a potentiometer to cycle through letters in the following character array (string) and print the result to the serial monitor.
char name[8] = “Stephan”;
Problem 15.43
Compare and contrast the use of interrupts versus polling of inputs.
Problem 15.44
Discuss the issue of latency in code: what it is, what causes latency, and how to reduce it?
Problem 15.45
Create a program that turns the Arduino into a voltmeter (0–5 V only!) using two analog pins A0 and A1. The Arduino should print out the voltage at the two pins and the difference between the two pins in both polarities. The voltage should be expressed in volts, not in the decimal numbers from the ADC. Hint: Write a function that performs the function of a DAC in software to print out values.
Problem 15.46
Implement a code that uses an external 2-bit flash ADC to read values on four digital pins and convert the result to a 2-bit binary.
Problem 15.47
Create a program that flashes an LED every second without using the built-in delay function.
Problem 15.48
-
A.
Create and present a program that will increment a counter on a button push. The counter is then used to blink an LED that many times per minute.
-
B.
Design the corresponding circuitry and present the circuit outline.
Problem 15.49
Update the code from the previous problem and the corresponding circuitry to add a decrementing counter. Make sure the result of the LED blinks per minute does not go negative or cause a runtime error.
Problem 15.50
Design and implement the code and the corresponding circuitry that will actuate a motor in two directions without using the servo library.
The circuitry should use two push button switches to choose the direction.
Problem 15.51
Write a program that counts hexadecimal numbers from 0 to F every second and displays the count on a seven segment display as shown in the following figure. The program that drives the 7-segment display must manually set the digital pins high corresponding to the value to be shown.
Problem 15.52
Write a program that acts as a burglar alarm. The corresponding schematic follows. The alarm waits for the switch to be released and then turns on a piezo-buzzer as the alarm. The alarm should not reset if the switch is reset (only after resetting the Arduino). The piezo can be sounded by simply writing a PWM signal to it.
Problem 15.53
Create a program that will read the voltage across the capacitor and print the value to the screen (one voltage reading per line) for the circuit in the following figure. Also print out the time measurement along with the voltage. Hint: In order to observe voltage variation across the capacitor, a square wave must be applied to pin 10.
Problem 15.54
Create a program that uses two light sensors (LDRs) to actuate a motor in two directions. The sensors are modeled by voltage dividers. In order to run the motor in two directions, two digital pins are used on the Uno.
Problem 15.55
Create a program that turns the Arduino into a reaction time calculator. A sketch is shown in the following figure. The program starts a countdown of LEDs when the start button is pressed. The program then counts the time it takes the user to press the end button once the final button has been pressed.
Problem 15.56
Write a program that turns the Arduino into a rudimentary stopwatch. The Arduino should begin “timing” after the push of a push button and then “stop” timing after a push of a different button. A sketch is shown in the following figure. Hint: Use some of the built-in timing features.
Problem 15.57
Implement a “lap” feature which spits out the time elapsed instead of stopping the count. A sketch is shown in the following figure.
Problem 15.58
Write a program that will control a 7 × 5 LED matrix as shown in the following figure. In order to make an LED the cell {R1, C1} on C1 must be LOW and R1 must be HIGH. Hint: This problem involves the use of arrays and several functions.
Problem 15.59
Write a program and create external circuitry that mimics the ball drop at New Years. The “drop” should start when a button is pressed and counts down 10 LEDs. The final LED stays on. Hint: Use a function to create the ball drop.
Problem 15.60
Create a program that will generate a square wave on pin 10 of the Arduino with the following frequencies:
-
A.
25 kHz
-
B.
7 kHz
-
C.
300 Hz
-
D.
2 Hz
Problem 15.61
Write Arduino code that generates a 20-Hz square wave on pin 7 without using delay or delayMicroseconds function.
Rights and permissions
Copyright information
© 2016 Springer International Publishing Switzerland
About this chapter
Cite this chapter
N. Makarov, S., Ludwig, R., Bitar, S.J. (2016). Embedded Computing. In: Practical Electrical Engineering. Springer, Cham. https://doi.org/10.1007/978-3-319-21173-2_15
Download citation
DOI: https://doi.org/10.1007/978-3-319-21173-2_15
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-21172-5
Online ISBN: 978-3-319-21173-2
eBook Packages: EngineeringEngineering (R0)