Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 : Push buttons Push buttons are simple components that include an open circuitry that mechanically closes when you push the button, allowing electricity

Part 1: Push buttons
Push buttons are simple components that include an open circuitry that mechanically closes when you push the button, allowing electricity to flow through the circuitry thus completing a task. The buttons we have in our disposal have four connections, but essentially they have two pairs of electrical connections - two on one side (positive) and two on the other (negative).
First, connect a male-to-male jumper wire to the GND slot on the digital side (next to pin number 13) and connect the other end of the wire to the negative column on the breadboard (See Figure 1). Then connect another jumper wire to the negative column and any row on the breadboard. To the same row, connect the negative lead of the LED. Connect the positive lead of the same LED to another row, which will also have one end of the resistor. Connect the other end of the resistor to another row, which will also have a male-to-male jumper wire connected to it. The other end of the jumper wire will be in pin 5, which will be defined as the LEDpin.
Now, let's do the inputs. Put five push buttons on the breadboard in such a fashion that they are slightly apart from one another (so that it is not difficult to press each one). Also, they should be standing over the channel in the middle to be able to utilize the two ends (+/-) separately. Wherever you connected the negative ends of the buttons, use male-to-male jumper wires to connect those rows to the negative column. Then connect their positive ends to pins 7,8,9,10, and 11, which will make these buttons #1,2,3,4, and 5, respectively, using male-to-male jumper wires.
In the code (Activity6a.ino), we are first defining the six pins we are utilizing. We use number 5 for the LED as the output pin, and numbers 7,8,9,10, and 11 for the push buttons as the input pins. Then in the setup we are defining our input and output pins. In the loop, we are defining
that the push of the first button will light the LED, the push of the second button will make the LED go on and off at 1Hz, the push of the third button will make the LED go on and off at 4Hz, the push of the fourth button will loop "Morse" ing the phrase "SOS" (3 dots -3 dashes -3 dots, 0.75 second dashes, 0.25 second dots, 0.25 seconds within letter dashes / dots, 1 second in between letters, 2 seconds in between phrase loops), and the push of the fifth button will turn off the LED. Please pay special attention to the use of updateFlag, and the associated flag variable to determine at any time if any button is pressed. Also please observe how we are calling the updateFlag function frequently so that the trigger of a button press can be caught at virtually any given moment. This is because any line of code can be completed within a few clock times of the processor, and the speed of the processor is 16MHz. That means, the processor completes roughly 16.8 million operations within a second. Therefore, a few clock times of the processor is not much. Let's say a line takes 10 clock times (which is an overestimation for many lines). That means, executing that line will take roughly 1.68 millionth of a second (00 nanoseconds).
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AutoCAD Database Connectivity

Authors: Scott McFarlane

1st Edition

0766816400, 978-0766816404

More Books

Students also viewed these Databases questions

Question

121. If X is uniformly distributed on [1, 3], find the pdf of Y X2.

Answered: 1 week ago