The tab book of arduino projects pdf

Sunday, May 12, 2019 admin Comments(0)

ma, 25 mrt GMT the tab book of pdf -. Tab (tablature) and notation of songs by other musicians as PDF di, 26 mrt Shields By Simon Monk #e8e EBOOK EPUB KINDLE PDF. Read Download. Online The Tab Book Of Arduino Projects: Get Instant Access to PDF File: #e8e The Tab Book Of Arduino Projects: 36 Things To Make With Shields And Proto Shields

Language: English, Spanish, Arabic
Country: Slovenia
Genre: Politics & Laws
Pages: 126
Published (Last): 20.01.2016
ISBN: 323-3-18876-544-1
ePub File Size: 28.54 MB
PDF File Size: 20.64 MB
Distribution: Free* [*Regsitration Required]
Downloads: 32323
Uploaded by: HERSHEL

Introduction T his book contains 36 Arduino projects. Some are easy to make, whereas others require some expertise with a soldering iron. You do not need a. The definitive collection of Arduino projects for the hobbyist and experimenter, The TAB Book of. Arduino Projects: 40 Things to Make with Shields and Proto. In this easy-to-follow book, electronics guru Simon Monk shows you how to create a wide variety of fun and functional gadgets with the Arduino.

You can test the program by opening a text editor or empty word processor document and then tilting the board to see the key commands appear. Cut off the excess lead from the resistor at the end nearest the Arduino header, but leave the other end long because you will use it to connect to R2 the variable resistor. The original instrument used radiofrequency electronics and a pair of antennas. The lighter it is, the faster the LED will lose its charge. Protoshields Many of the projects in this book make use of a Protoshield Figure I First, it shows that everything is set up okay and that your computer can communicate with the Arduino to program it. To create the display object, the following line of code is used:

When soldering the LED, make sure that the longest lead the common cathode is the second lead down from the top of the board. This is the lead that will be connected to ground and not to a resistor. Also make sure that the screw terminal is attached with the open end, where the wires go toward the outside of the board. When everything is connected, the underside of the shield should look something like Figure Figure shows a diagrammatic version of the underside for easy reference.

Note that the board has been flipped left to right so that the screw terminal is at the right of the diagram now. You will notice that near the screw terminal and the MOSFET, there are some links made with the component leads that need to jump over other solder pads without making contact.

Software There is an Arduino library that greatly simplifies using a keypad. This library needs to be downloaded from the following URL: Later, when you deploy the lock for real, you will need to use the V power supply to provide enough voltage and current to operate the door latch. Much of the code for this project is very similar to that of the RFID door lock of Chapter 5, so you also may wish to refer to that chapter. Here I will just present the parts of the sketch that are different.

We then have a variable that keeps the secret code. The loop function is as follows: Here we first define a Boolean flag called wrong that will be set to true if a wrong digit is entered as the code. Once this key has been pressed, there is a loop that captures the next four key presses and compares them with the appropriate digits of the secret code.

If any of the digits are wrong, then the wrong flag is set. After all four key presses have been captured, then either the door is unlocked or locked depending on the result in the wrong flag. Unlocking the door is similar to the sketch of Chapter 5, except that in addition to setting the color of the LED, the program also sounds the buzzer continuously for the 5 seconds that the latch remains unlocked. Sounding the buzzer requires use of the Arduino tone command. The first parameter of this command is the pin on which the tone is to be played, and the second is the frequency of the note in hertz.

The noTone command cancels the buzzing sound at the end of the 5 seconds, after which the door is then locked again using the following lockDoor function: The lockDoor function also gets called as a result of entering an incorrect code.

Therefore, to make the failure to enter a correct code obvious, a for loop is used to make the LED flash red and the buzzer sound five times. The final function that I need to mention is waitForKey. This function will wait until a key has been both pressed and released. The first while loop waits until a key is pressed. The second while loop waits until the key is released again. The lock is unlocked using a solenoid that requires a few hundred milliamps to activate.

This is why the Arduino needs to be powered from a 12 V 2 A power supply. The LED will be red when the lock first starts up.

Note that the buzzer will warble for a few seconds if you are using an Arduino Leonardo. Once reset is complete, setup calls the lockDoor function, so the LED will flash red and the buzzer will sound four times. Enter the four-digit code , and the LED will go green, the buzzer will sound, and the door latch will be released for 5 seconds, after which the lock sequence will run again.

However, instead of using a radiofrequency identification RFID tag reader or keypad, this version of the lock uses a secret knock Figure The idea is that you train the lock with a certain pattern of knocks, and then, when it hears the correct knock, it releases the door. This type of lock should not be considered to be as secure as the preceding two lock projects but is a great bit of fun.

Most of this design is exactly the same as that of the keypad lock in Chapter 6. All the headers can be normal 0. Construction Start by following the instructions for constructing the Protoshield in Chapter 6, but use normal header pins throughout rather than stackable headers.

Note that even after you have added the extra parts, the hardware will still be compatible with the keypad lock project of Chapter 6. Then solder in the pair of header pins. Figure shows the additional components on the Protoshield. Wire the Underside Now bend the resistor leads so that they brush the edge of each header pin and continue on to the Arduino GND and A0 connections on the Protoshield. Figure shows the additional wiring on the underside of the Protoshield. Software The software for this project is the most complex of the three door lock projects.

The section of constants above this might need changing to suit your particular buzzer. See the next section if you need to do this. When the Arduino restarts, the setup function will turn the LED blue, expecting you to immediately enter the secret knock key. The function records this key using the recordKnock function and then plays it back using the playKnock function. The recordKnock function is as follows: This function will write the knock timings into whatever array is passed to it as an argument.

It uses the first element of the array to record the number of taps detected, and the remainder of the elements of the array will contain the duration in milliseconds after the start of recording t0. The while loop ensures that the maxRecordingTime and maxTaps are not exceeded because this would cause unpredictable results if the array bounds were exceeded and fixes the recording time at 5 seconds.

The function recordKnock relies on the function tapDetected to determine whether the sensor has been tapped. The function tapDetected returns true if the reading on the analog input A0 is above the threshold. However, it delays for ignorePeriod to ensure that the ringing effect that might cause a knock to be detected twice is minimized. Playing back the knock is a similar process to recording it. The function playKnock is as follows: To play back the knocks through the buzzer, we need to step over each element in the array, make a short buzz, and create a delay for the time difference between the current knock and the previous one.

The main loop function is as follows: Nothing will happen in the main loop until a tap is detected. This then triggers the sequence of events necessary to capture a series of taps on the sensor. The LED is set blue, and then the recordKnocks function is called. The if statement uses the guessCorrect function to check whether the knocked sequence is close enough to the saved pattern. If it is, then the door is unlocked. The guessCorrect function is as follows: The first thing that happens in this function is that the lengths of the guess and key knocks are compared.

If they are not the same length, then they cannot match, so false is returned. If they are of the same length, then the time of each tap has to be compared in turn. Because the knocking is unlikely to start at the same time after the LED went blue, the startGap variable is set to a value to synchronize the two sequences of knocks.

The error of a particular guess is calculated as the absolute value of the difference between the guess knock and the key knock less the startGap. If that error is greater than the limit in milliseconds specified in tapLeeway, then false is returned. Installing and Using the Door Lock The type of latch used is designed to replace the receptacle for a conventional lock so that when power is applied, it allows the receptacle to swivel and the latch to open.

This is why the Arduino needs to be powered from a 12 V, 2 A power supply. There are a number of constants at the top of the sketch that can be tweaked to alter the performance of the lock. The constant threshold is the value of analog reading above which the reading will count as a knock. If you find that the lock is too sensitive and registers knocks when there were none, then increase this value.

The ignorePeriod value will help to eliminate double taps where there was only one. Increase this value if you find this happening. When comparing the knocks, the value of tapLeeway specifies the number of milliseconds that the guessing taps can deviate in timing from the key taps. If you want to make the lock more lax, then increase this value. Summary In Chapter 8 we will look at using a sound shield to play the sound of a dog barking when a panic button is pressed or motion is detected using a passive infrared sensor.

Unlike most of the projects we have built so far, this project uses a ready-made shield for playing the sound file. The MP3 player shield is equipped with a 3. This is ideal for connecting to a pair of powered computer or MP3 player speakers. The louder the better! Unless you plan to record a very large amount of dog barking, any micro SD card bigger than MB will be fine. Design Figure shows how the switch and PIR sensor are attached to header pins that fit into the header sockets of the shield.

The push switch grounds the digital input when it is pressed. Construction Because most of the work is already done for us in the ready-made shield, this project is easy to make. Because there are going to be a few extra things that we need to attach to the Arduino, we will use through header pins Figure To solder these in place, start by soldering just one pin on the underside of the board. Then straighten the header row up by melting the solder again while you get it level and flat to the board.

Then you can solder the rest of the pins on that header and then repeat the process for the other headers. When all the headers are attached, the finished board should look like Figure Attach the Push Button Solder short leads of multicore insulated wire onto the push button.

Then solder the other end of one of the leads to the GND pin indicated in Figure Attach the other lead to D12 on the header. Again, use Figure as a reference. Data have to be set to it a byte at a time. Fortunately, to simplify this process, a library has been developed that you need to download and install into your Arduino environment. First, download the the zip file from www. For the libraries to be recognized, you need to restart the Arduino software. You may prefer to record your own deterrent sound.

If you do, then this must be in MP3 format recorded at kbs. Remember to name the file track When the file is ready, remove the micro SD card and insert it into the holder on the MP3 shield.

Of the pdf book projects tab arduino

Using the Fake Dog Once built and programmed, this project no longer needs to be connected to your computer for anything other than power. Therefore, you probably will want to power it from an external power adapter. Ideally, the PIR sensor will be positioned outside your door, with wires running into the house and connecting to the shield. Software The library makes the sketch itself nice and simple.

This tells the library to look for a file called track The remainder of the code is mostly concerned with checking the digital inputs one for the PIR and one for the switch. Summary This is a fun project to make and could be adapted to other uses.

To improve the project, you could record a number of different tracks and have them played at random when triggered. Construction The project uses header sockets to connect the modules. If you prefer, you can just solder them directly to the Protoshield.

Step 1. However, you may choose to omit the pins for the Arduino pins A0 to A5 as these are not used in this design. Step 2. Solder the Components to the Protoshield The header sockets can be cut from a long length of header sockets see Chapter 3 for details on how to do this.

There are only two header sockets and the push switch to attach, so they can all be soldered in one go. Use Figure as a reference for positioning the header sockets and the switch.

Figure shows the top side of the completed Protoshield. There are a few places where wires cross over each other, so use insulated wire where necessary. The zip file is small, so it will not take long to download. After the library include statement, you will find the definition for the constant threshold. This specifies the maximum distance of an object from the sensor for that object to be counted. This distance is in centimeters. This is followed by the usual pin definitions.

The ultrasonic range finder uses two Arduino pins, trigger and echo. To count objects moving past the sensor, we need to detect when they are inside the threshold distance and then wait until they move further away than that distance.

To keep track of these two states, we use the constants waitingForArrival and waitingForDeparture and the variable state. The count variable is used to keep count of the number of objects that have passed the sensor. The setup function sets the modes of the Arduino pins and initializes the display. It cannot literally wait for such a thing using a while loop because it needs to also keep checking for key presses. If the state is currently waitingForArrival and an object has come close enough, then the state is changed to waitingForDeparture.

The next time around the loop, the state will now be waitingForDeparture, and unless the object has departed, it will stay in this state. When the object does depart, the count will be incremented by one, and state will return to waitingForDeparture. The next section of the loop function checks for a button press. Finally, the count is written to the display, and the display is updated.

The function takeSounding sends a short pulse to the trigger pin of the ultrasonic rangefinder and then times how long it takes for the echo pin to go HIGH, indicating that the sound wave has returned to the module.

The distance then can be calculated from this time taken. Using the Project You probably will need to adjust the direction in which you point the rangefinder and the value of threshold to get it to work well. Pressing the button will set the count back to zero. There are some interesting uses for this kind of project. For example, if it were battery powered and waterproof, then you could use it to keep track of how many lengths of a swimming pool you had swum.

In this case, you probably would want to increment count by two each time you got close to the edge of the pool where the counter is stationed.

It is also one that lends itself to various adaptations. In Chapter 10 you will find the final security-related project in this book, in the form of a laser-based intruder alarm.

TAB Book of Arduino Projects: 36 Things to Make with Shields and Protoshields

In this case, the triggering of the alarm activates a relay. This offers the best flexibility in attaching sirens, lamps, or various other devices in response to the alarm being triggered. Once triggered, the alarm remains active until the reset button is pressed Figure An alarm like this is really more for fun than for serious security.

It is actually fairly easily defeated using a sheet of paper placed close to the laser and an LED so that the light from the laser is reflected straight back into the LED. Because you are using the laser with a mirror, you need to be especially careful not to reflect it back into your eyes. To see if the laser is on, never look into it. Instead, hold a piece of paper in front of it to see the dot. Parts This project uses a Protoshield and a low-cost laser module. It also uses a clever trick to allow a large LED to be used as both the light sensor and an indicator of the alarm being triggered.

You can always add them later. Figure shows how this works. Notice how the LED is reverse biased. That is, it is the wrong way around if we want it to emit light. This way around, the LED will act like a capacitor think of a mini rechargeable battery. This will happen very quickly, so almost immediately there will be a voltage across it of 5 V.

If we disconnect point A, the voltage would gradually drop back down to zero. The speed at which it drops will depend on the amount of light falling on the LED. Thus, if having charged the LED we then switch point A to a digital input instead of an output, we can see how long it takes for the voltage to fall from being high over about 2.

This time will give us a measure of the light intensity. You can find an excellent description of this technique at www. Construction Aligning the Arduino and mirror so that the beam is neatly reflected back onto the LED is quite tricky and needs both the mirror and Arduino to be anchored securely in position.

If you are going to use this project for real, then you probably also will want to run leads to the switch rather than have the switch on the board and easily pressable to cancel the alarm.

Figure shows the Protoshield layout. Because stability is important for this project, it is probably a good idea to solder all the header pins. Thus, the leads have been carefully bent out so that the relay can be soldered to the top surface of the board Figure The relay now can be soldered to the top of the Protoshield in the position marked by Figure Figure shows the relay soldered into place.

Solder the Remaining Components to the Protoshield You can now solder the rest of the components to the board. Do not trim off the excess leads from the components because they will be useful later when you connect things up on the underside of the board. There are a few things to check when you are soldering: Figure shows the remaining components soldered into place.

Solder the Underside of the Protoshield You will be able to make most of the links on the underside of the board using the component leads. However, you will need a couple of longer lengths of wire for connections to the screw terminals and switch. Figure shows the underside of the board, and Figure shows the wiring diagram from the underside of the board.

The sketch does not require any Arduino libraries to be installed. The pin definitions for this sketch are as follows: These pins are needed to allow the polarity of the LED to be reversed when switched between emitting and sensing light. The laser is controlled by laserPin. This allows the sketch to turn the laser off briefly, when measuring the ambient light intensity.

The constant laserNoLaserRatio determines by how many times the light-level reading must be lower with the laser lighted than without it before the laser beam is interrupted, and alarmTriggered is activated. A Boolean variable is used as a flag to indicate that the beam has been interrupted. The setup function simply sets the pin modes of the various pins. The first part of this function tests to see if the laser beam has been interrupted. If it has, then it sets alarmTriggered to true.

It will remain set to true until the button is pressed. This is detected in the next section of loop. The alarmPin is then set to the same value as alarmTriggered. Also, if the alarm is triggered, then the flashLED function will be called, temporarily reversing the polarity of the LED to make it light rather than act as a light sensor.

To decide whether the beam has been broken or not, the function laserOnTarget is used. This function first reads the light intensity with the laser turned on, then turns the laser off, waits for 10 milliseconds, and then takes another reading, before turning the laser back on. The readings are lower the higher the light intensity, so the laserOnTarget function will only return true if the reading taken with the laser on is significantly less than the reading with no laser.

The following function reads the light intensity: It then returns the time taken in microseconds. The lighter it is, the faster the LED will lose its charge. You will remember that when the alarm is triggered, the LED is made to flash. This happens in the function flashLED. Before the LED can be used to light up rather than act as a light sensor, it must be forward biased by setting ledPinA to be an output and low. Using the Project In using this project, you will need to find a place to position the mirror so that it can reflect the laser light back onto the LED.

The way to do this is to attach the mirror to a wall self-adhesive putty is useful for this. The Arduino and shield then can be positioned opposite the mirror. Because there is a short distance between the laser and the LED, the laser module will need to be bent ever so slightly so that the reflected laser dot falls on the LED.

You will see the LED glow when this happens. A relay Figure is basically an electromagnet that closes switch contacts. Although the coil of a relay is often energized by between 5 and 12 V, the switch contacts can control high-power, high-voltage loads.

Of the tab arduino projects pdf book

For example, the relay shown in Figure claims a maximum current of 10 A at V alternating current ac, mains as well as 10 A at 24 V. Because the relay contacts will behave just like a switch, you can use the relay to switch almost anything.

TAB Book of Arduino Projects: 36 Things to Make with Shields and Protoshields

The wiring diagram in Figure shows how you could use the relay with a 12 V alarm sounder and power supply. Summary This is the last of the security-related projects in this book. In the next section, you will find projects relating to sound and music. The original instrument used radiofrequency electronics and a pair of antennas. By moving your hands in front of these antennas, you could control both the pitch and the volume that the instrument produced.

This Arduino version does not use radiofrequencies to convert hand positions into sound but rather uses an ultrasonic range finder. The distance sensed will determine the pitch of the sound Figure These devices are inexpensive and easy to find.

You can, if you prefer, solder the range finder directly to the shield or, as described here, use a header socket. Construction This is a simple project to make. The only slightly tricky part is to solder the 3. Figure shows the schematic diagram for the project, and Figure shows the layout of the components on the Protoshield. If you are unsure how to do this, refer to the Introduction to this book. There is only one hole to drill, and because you are just widening the hole to 1.

Figure shows the Protoshield with the socket soldered in place. Solder the Remaining Components The rest of the components are just soldered in the normal way. Cut off the excess lead from the resistor at the end nearest the Arduino header, but leave the other end long because you will use it to connect to R2 the variable resistor. When all the components are in place, the top of the board will look like Figure Link the Components Start by bending the remaining resistor lead so that it joins one end of the variable resistor.

You will need to use linking wires for all the remaining connections. Use Figure as a guide for where the wires should go. Use insulated wires where they cross other wires. When all the links are in place, the bottom of the board should look like Figure Figure shows the wiring layout from the underside of the board.

Software This project uses a very sophisticated Arduino library to do all the clever tone-generation stuff. The function sets the frequency of the tone being generated. The function updateAudio gets the next value for the sound wave. Thus, for the sine wave we are using here, this will be the next value from a table of sine waves. The range finder works by measuring how long it takes for a sound pulse to reflect from an object. To do this, you have to send a pulse to its trig pin and then wait for the echo pin to indicate that the sound has returned.

Using the Instrument Connect the Protoshield up to the amplified speakers or even your home stereo system. The instrument will not start making a tone until your hand is about a foot away from the range finder. Moving it toward the range finder will lower the tone; moving it away will raise it. In Chapter 12 we will turn our attention to making an Arduino-controlled FM radio receiver.

Predefined stations are stored in the sketch, and a push-button switch is used to change stations. You also could easily modify the sketch to change channels using serial commands. This project uses an audio jack to output the received stereo signal. This will then need amplifying by connecting it to powered speakers. The TEA radio modules have solder connectors that are 1 mm apart rather than the 0. This means that you cannot solder these modules directly to the Protoshield, but instead, you need to use an adapter PCB that will allow the module to be used with the Protoshield.

Construction Figure shows the Protoshield layout for this board. One feature of the design is that the TEA module is powered from the 3. The module will work just fine at 5 V, but it was found that when the display module was attached, a great deal of interference was generated on the 5 V supply line. Using the 3.

Thus you can leave out the other pin headers if you wish. Figure shows the sequence of steps involved in this. Figure a shows the module next to the PCB. Although it is tiny, the main problems when soldering it is not so much that it is small but that it is likely to move around. To fix this, a tiny piece of adhesive putty can be placed under the module. Squash the radio module onto this, making sure that it is oriented correctly with the metal tubular crystal at the bottom of the PCB.

You can then carefully squish the module around a bit until its solder pads line up directly with the pads on the breakout PCB Figure b. You will need a soldering iron with a fairly fine point.

Press it into the junction of the module connection and one of the pads on the PCB, and then feed in a bit of solder Figure c.

If you end up with solder bridging neighboring pads, you should be able to remove it easily with desoldering braid.

Press the braid on top of the affected areas with the soldering iron. Finally, solder on the header pins as you would with a Protoshield Figure d. Attach the Audio Socket This project uses the same audio socket in the same position as the project in Chapter So please refer to that chapter to prepare the leads on the socket and drill out one of the holes so that it can fit securely onto the Protoshield.

Then solder the socket to the board. When this is complete, it should look like Figure Attach the Components Now attach the switch, breakout board, and header socket to the Protoshield.

Make sure that you get the breakout board the right way around see Figure 2. Do not push the leads of the breakout PCB all the way through, or if you are going to use an Arduino Uno, the leads will foul the pins of the ATMega chip on the Arduino. Therefore, just push the pins through enough to solder them. This will leave the breakout PCB standing proud above the Protoshield by a few millimeters. When the components are all attached, the Protoshield will look like Figure Solder the Underside of the Board Figure shows the wiring from the underside of the board.

Note that because none of the modules have long leads, you will need a good supply of solid-core wire for hooking up the connections on the underside. When the underside of the Protosheild has been wired, it will look like Figure Make an Antenna The simplest kind of antenna to use with this receiver is a length of wire. This should be about 2 ft. Strip one wire, and solder the other through the top of the board at a hold adjacent to the ANT pin of the TEA module, and then connect the wire to that pin.

Figure shows this connection. The project needs a few libraries to be installed into the Arduino environment: The Adafruit libraries are the same as those used in Chapters 15, 21, and The icon on the webpage is labeled zip and looks like a cloud with an arrow coming out of it.

Before uploading the software, you will need to change the frequencies specified in the array freqs. Choose frequencies that you know correspond to radio stations in your area before uploading. The TEA library is very easy to use. To start the radio, you just need the following line: A similar line is needed to start the display. This simply loops, doing nothing until the button is pressed.

When this happens, the channel number is incremented. If this makes channel equal to 12, or if the freqs array value for that channel is 0, it sets the channel back to 0. The radio module is then told to change to the new frequency indicated in the array, and the display is updated.

Before returning to the loop, there is then a delay of milliseconds to prevent key bouncing. Displaying the frequency requires a bit of manipulation of the frequency value because the Adafruit library does not directly support the display of floats. The function is listed as follows: The first step is to clear the display, making it ready for the new value to be written.

Next, a variable f10 is defined that is an int value of 10 times the frequency. Thus, if the frequency for the current channel is The lines of code that follow this split this four-digit number into four separate numbers by taking the modulo remainder and dividing the number by 10 and then dividing that number by 10 to move up through the digits. The if statement is used to suppress the displaying of the first digit if it is 0.

The first is the digit position. Rather confusingly, these are 0, 1, 3, and 4. That is, digit 2 is skipped because this digit is actually reserved for the colon in the center of the display. The second parameter to writeDigit is the single-digit value to display, and the final parameter is whether to display the dot for that digit. We are fixing the decimal place at the last but one digit, so this parameter is only true for digit 3. Summary In the next couple of projects we will build devices for controlling music software such as Ableton Live.

I have, however, provided a second version of the design that is intended for use with separate switches that you might fix into a box and then run leads back to a screw shield on the Arduino. The project is intended for use with music software such as Ableton Live as a simple controller. Therefore, you press one of the buttons, and that triggers some action within the music software—say, starting a drum track playing.

In effect, you are making something that will emulate a computer keyboard that has most of the keys removed! Figure shows the Protoshield version of the project, and Figure shows the screw-shield version.

This is one project that does require the use of an Arduino Leonardo. This version of the Arduino has the ability to emulate a keyboard. This is something that is not possible with the Arduino Uno. Parts Protoshield Version This version of the project has tactile push switches attached to a Protoshield and is therefore of more use for fingers than feet.

Construction Protoshield Version The switches are arranged in a diamond pattern around the Protoshield. Note that the switches have a pin spacing that is longer in one direction than in the other, and the switches are not all oriented the same way. This project uses pins from all four headers, so you will need to solder on a full set of header pins. Solder the Switches to the Protoshield Using Figure as a reference and making sure that you have each switch the right way around, push the switches into the Protoshield.

The switch leads can be a little delicate, so make sure that they are all lined up with the holes before pushing the switches firmly into place. Try to keep the switches level. When they are all soldered to the board, it will look something like Figure 4.

Step 3. Solder the Underside of the Protoshield Figure shows the underside of the board, and Figure shows a schematic diagram of the underside. None of the wires cross over each other, so use Figure as a reference to connect the components on the underside of the board. Parts Screw-Shield Version This version of the project uses a ready-made shield called a screw shield Figure There are many versions of this kind of shield, and it allows you to attach wires to Arduino pins using screw terminals, which is perfect for, say, attaching a load of switches to an Arduino.

In this project, you can attach as many switches as you like to the Arduino, only limited by the number of pins available. Thus, you could attach pins to D0—D12 and A0—A5, which is 19 buttons.

This design uses 10 buttons. Construction Screw-Shield Version This design is built into a section of rectangular pipe with access holes cut in one side to allow access to the switches and Arduino.

You may prefer to find a more robust enclosure. All that is really necessary is that it has enough room to easily press the switches that you want to use. Prepare the Enclosure Work out where the Arduino and screw shield are going to fit in the enclosure, and drill some holes to bolt the board securely into place. Also drill holes for the switches.

Figure shows the front of the prepared drain pipe from the front, and Figure shows the rear. Fit the Switches You can now fit the switches through the holes as shown. Line up the contacts on the back so that it will be easier to run the common GND wire that will go to one contact of every switch. With the switches in place, the enclosure looks like Figure Figure shows a wiring diagram for the switches.

Because it is a little tricky to get access to the switches, I first connected together 10 short lengths of wire matching the GND connection to all the switches outside the enclosure Figure and then soldered them onto the switch terminals, leaving one lead to be connected to the screw terminal GND.

Solder the Separate Wires to the Switches The other terminals of the switches each need a longer wire reaching to it that will reach all the way to where you are positioning the Arduino and Protoshield. If the wires are longer than they need to be, this does not really matter because they can just be tucked into the enclosure.

It is certainly easier this way than with wires that are too short. In addition, it is probably best to attach each wire to the screw terminal as it is soldered to the switch, to avoid confusion about which wire is which. When all the wires are in place, the back of the pedal board should look something like Figure Software The sketch is more or less the same, but you have many buttons and you must choose whether you use the Protoshield design or the screw-shield design.

In the downloads for the book on my website www. The descriptions of the code that follows are all taken from the four-switch version.

The reason that the same software will work with both sets of hardware is that the number of switches, the Arduino pins that they use, and the key presses that they simulate are all specified in three variables. These are the only changes to make the sketch work with a different number and arrangement of switches. The following section of code defines a constant and two more arrays used to make sure that the keys do not bounce, causing multiple triggerings for one key press, or autorepeat, sending the same key press continually while the key is depressed: The constant debouncePeriod specifies the time delay after one press of a particular button before that button can be pressed again.

This is used later in the code to debounce the button presses. If you find that you are getting unwanted double or triple clicking of a button, then increase this value.

The array pressed is used to keep track of the state of each switch, that is, whether it is pressed or not. This is so that you can make sure that no further button presses will be registered for a button until it has been released. The following setup function uses a loop to set all the pins used to be inputs pulled up to 5 V: The setup function also puts the Arduino Leonardo into keyboard emulation mode using the Keyboard. Most of the work takes place in the following loop function: The loop function will check all the switches listed in the switchPins array in turn.

It first uses a digitalRead to see whether the switch is pressed and sets the local variable keyPressed accordingly. It then sets a variable timeNow to the number of milliseconds since the Arduino last reset and then sets a second Boolean variable called tooSoon based on whether debouncePeriod milliseconds have elapsed since the key was last pressed. We then have a pair of nested if statements.

The outer one checks that the key was pressed. If it was, then the second if statement first makes sure that the key is not still pressed from last time and that sufficient time has elapsed since it was last pressed.

If both these conditions are true, then it pretends to be a keyboard and sends the corresponding key for that switch. It then updates the lastPressedTime for that key and marks it as pressed. In the situation where the switch was not pressed, its pressed status is set back to false. You can test the program by opening a text editor or empty word processor document and then pressing the buttons to see the key commands appear.

Using the Project One way of using this key pad is to make yourself a virtual drum set, where each button is allocated to a different drum sample.

To do this in Ableton Live, the first step is to add four samples to the session view. You might, for example, use four different audio drum samples from your library arranged like the example of Figure The next step is to assign the keys to the different samples.

This puts Ableton Live into a key-mapping mode. Select one of the clips, and then press one of the buttons on the controller. Repeat this process for the other three buttons. You also could use this controller to switch between different drum beats or sections of a song to allow the basics of DJ-ing.

Summary This is the kind of project that could be used for other things. You would have to change the sketch a little, but you could store passwords associated with each of the keys or other items of text that you might want to simulate typing at the touch of a button.

It uses an accelerometer module to detect movement and generate key presses Figure An acceleration module can be used to measure the force of gravity acting on the module.

You can use this effect to calculate the angle to which the module is tilted in both the X and Y directions. The module is a three-axis accelerometer that measures the force applied to a tiny weight inside the chip. There normally will be a constant force acting on this dimension due to gravity. Therefore, if you tip the module, the effect of gravity starts to increase in the direction in which you tip it Figure Parts Just as with the preceding project, this project requires the use of an Arduino Leonardo for its ability to emulate a keyboard.

Construction As you can see from Figure , this is a very simple project to build because the accelerometer module will plug directly into the analog socket section of the Arduino. If pins A0—A5 have been used previously as digital outputs, then plugging the module in before uploading the sketch could easily damage the module, the Arduino, or both.

Solder Header Pins onto the Acceleration Module The acceleration module is supplied without header pins attached. Thus, the first step is to solder them on. This will also then line up with the six pins A0—A5 on the analog connector. Remember not to plug the accelerometer into the Arduino Leonardo before you have uploaded the sketch. The first constant in the sketch defines the keys to be used when the accelerometer is tilted back and forth. The next set of constants defines the pins that are to be used.

To keep the wiring as simple as possible, power is supplied to the module through A0 acting as a digital output set to HIGH. We do not want to use this, and we prevent it having any ill effects by setting the pin so that it is connected to a digital input. The offset constant is the analog reading for the X and Y directions when the board is level.

The setting of pin modes happens in the setup function as usual. The setup function also starts the keyboard emulation. The loop function first reads the values of X and Y and adjusts them by subtracting offset. This gives a number that is more or less zero until the module is tilted. Each time around the loop, the variable keyIndex is set to a value between 0 and 7 based on the value of y. The two single-line if statements just constrain the value of keyIndex. The key is only simulated as being pressed if it has changed and the absolute value of x is less than 20; that is, the accelerometer is almost level in the X axis.

Before the key is depressed, though, the Keyboard. You can test the program by opening a text editor or empty word processor document and then tilting the board to see the key commands appear.

Thus, all that you need to do is to drag a virtual instrument onto the session view, and make sure that the track for the virtual instrument is armed the dot button at the bottom of the track containing the virtual instrument. Finally, turn on the computer MIDI keyboard using the icon on the toolbar. When this is fully set up, your Ableton Live window should look something like Figure Tilting the controller forward and backward will turn the sound on and off, and tipping it slightly to the left or right will select the note to be played.

Summary The next project is the final project in this section and uses a multicolor display to show a frequency spectrum of music or other sound used as its input. This project would make a nice addition to any audio system.

Displaying the spectrum of an audio signal involves splitting the signal into a number of frequency bands and measuring the magnitude of the signal at each band. The human ear or, rather, the young human ear is usually assumed to be able to detect sound waves between 20 Hz and 20 kHz.

Perception of pitch is logarithmic in nature, so the frequency bands are not evenly spaced. You can also see in Figure that the project is attached to an Android smartphone. This phone is running a free app called Signal Generator.

This app can be used to generate a pure sine wave of some particular frequency. In this case, the frequency is 1 kHz, resulting in the peak frequency in the 1 kHz column of the LED display. Using such an app is a great way of testing the project before you try it on music. Such apps are also available for Apple and Windows smartphones as well as PCs. Parts To build this project, you will need the following parts: To connect an audio device to this project, a normal 3.

It is cut in half so that the spectrum display sits between the source of the sound say, an MP3 player or computer and the amplifier responsible for making the signal audible. If you prefer, you can use a pair of 3. This shield actually uses two MSGEQ7 chips, allowing both the left and right audio signals to be monitored. Construction This project is relatively easy to put together. The screw terminal is used for both the incoming and outgoing audio signals, but only one of the two stereo signals is actually monitored for the spectrum display.

Figure shows the Protoshield layout for the project.

This chip contains an amplifier and seven notch filters that are used to find the strength of the signal at seven different frequency bands centered on 63, , and Hz and 1, 2. The analog output from the MSGEQ7 will be for one of the channels, and you can switch the frequency-band value that appears on this output using two control pins.

When you send a pulse to the reset pin, it resets the chip so that it is ready to start taking readings. If you then send a pulse to the strobe pin, it will set the analog output to be read from the first frequency band.

Send another pulse to the strobe pin, and it will move on to the next channel and so on for all seven filter values. You can find out all about this chip from its datasheet, which is available at www. Solder the Header Pins onto the Protoshield The Protoshield uses connections on only three of the four connection headers, so if you want to save some headers, just connect the two sections of the header pins that are used, that is, SCL to D8 and both connectors on the opposite side of the board.

Solder the Resistor, Capacitors, and Integrated Circuit Holder Start with the resistor the lowest component on the board. Solder in the resistor, then the IC socket or the IC if you are not using the socket , and then the capacitors. Make sure that this is toward the top of the board. Figure shows the Protoshield with these components in place. Do not snip off the excess leads of the resistor and capacitors yet.

You can use them later to connect the underside of the board. Solder the Screw Terminals and Header Pin Socket The header socket is supplied as long strips, and you will need to cut it to a length of four header sockets. To do this, score the strip on the fifth socket with a kraft knife, and then break the strip off over the edge of a desk.

This means that you will sacrifice one of the sockets from the strip, but this works much better than trying to cut on the very narrow gap between the headers. Solder the header socket onto the board. Another trick is to put a lump of adhesive putty around the header socket to keep it in place while you solder it.

Figure shows the Protoshield with the remaining components attached. Note that I have used a four-way screw terminal block because I did not have a three-way block. Connect the Underside of the Board Use Figure as a guide to wiring the underside of the board and Figure 6 for the finished wiring.

Start by using the existing leads on the components where possible. Where you have one wire that needs to cross another, use insulated solid-core wire. Fit the Integrated Circuit and Display Integrated circuits are generally supplied with their leads a bit too far apart to easily fit into the IC socket, so you probably will need to bend the leads in a little before the IC will fit. The way to do this is to firmly hold the IC between finger and thumb and press one side of the leads down against your work desk Figure Be careful not to bend the leads too much.

The IC must be inserted with the little notch in the package toward the top of the board. You can see the IC in place in Figure With the IC inserted, the board now can be fitted onto the Arduino while we prepare the audio lead. The leads may have one outer shielded wire wrapped round a pair of inner insulated wires for the left and right signals or have three color-coded wires.

If this is the case, then left and right usually will be white and red, respectively. If in doubt, use a multimeter in continuity buzzer mode to determine which lead is connected to which part of the audio plug. Figure a shows the type of audio lead used. Figure b shows one- half of the lead stripped. The next step is to join the wires up again by twisting them together, as shown in Figure c.

Finally, Figure d shows how the wires fit into the screw terminal with the common-ground connection to the left of the figure. Software The use of a hardware filter chip to separate the magnitude of the different frequency bands greatly simplifies the software.

The alternative to this would be to use an amplifier chip and a software algorithm fast Fourier transform to produce the frequency analysis, but because we would need a chip for the amplifier anyway, we may as well have one that does a bit more for us.

This uses the same Adafruit libraries that we will use in Chapter 21 to drive the LED matrix display. To install the libraries for the LED module, go to https: These are defined in the following constants: The colors displayed at different magnitudes will vary, with green for low signals, yellow for medium, and red for high signals. These colors are specified in the following array: To create the display object, the following line of code is used: The setup function is as follows.

It simply defines the pin modes and initializes the display. Most of the work for this project takes place in the following loop function: It then puts a dot in the position 7, 0 of the display. Because the chip has only seven frequency bands but the display has eight, it looks better with something showing in the unused column.

It then reads the value from the analog input pin. An inner loop is used to effectively draw a line from the bottom of the display up the column that corresponds to the magnitude of the signal at that frequency band.

The colors array is used to determine the color of the pixel. The loop function uses the pulsePin command to generate a pulse on a pin supplied as its first argument for the duration in microseconds specified in its second. Using the Project You can test the project using a smartphone signal-generator app, as shown in Figure , by connecting just one of the leads to the phone. Try varying the frequency of the tone, and you should see the column corresponding to the frequency of the signal generator show the strongest signal.

When you are happy that everything is working as it should, then connect one end of the lead to your sound source i. In the next section, you will find a selection of projects that all use the Internet in some way. Parts This project is compatible with both the Arduinos Uno and Leonardo. The Ethernet shield uses to mA and may draw more current than the USB lead can comfortably cope with, so it is recommended that you use an external power supply.

You'll learn how to design custom circuits with Protoshields and solder parts to the prototyping area to build professional-quality devices. Catapult your Arduino skills to the next level with this hands-on guide. Build these and many more innovative Arduino creations: Simon Monk Abstract: Table of Contents A.

Dedication B. About the Author C. Acknowledgments D. Introduction A. Light and Color 1. Persistence-of-Vision Display 2. LED Cube 3. Color Recognizer B. Security 5. Keypad Door Lock 7. Secret Knock Lock 8. Fake Dog 9. Person Counter Laser Alarm C. Sound and Music Theremin-Like Instrument FM Radio Receiver Pedal Board Controller Music Controller Spectrum Display D.

Internet E-Mail Notifier Weather Data Feed