So one terminal of our test lead is damaged. As with LEDs, on polarized capacitors, fixed at 2. A positive voltage will mean a the schematic symbol is longer than the negative value at the analog input of greater than 2.
The negative lead also often has a — minus a negative value will mean a value at the analog or diamond shape next to the negative lead. Figure shows the completed oscilloscope.
Figure Schematic diagram for Project Software of dividing it by four and making it fit into a single byte. The sketch is short and simple Listing Project Its only purpose is to read the analog input and We obviously need some corresponding blast it out to the USB port as fast as possible.
This can be The first thing to note is that we have increased downloaded from www. To get as much data through the connection as To install the software, you first need to install possible without resorting to complex compression the Ruby language on your computer. Then just type: void setup ruby scope. Install the software for your Serial. To pick it up, all you have to do is with the USB port. To install this, open a touch the test lead connected to the analog input command prompt in Windows or a terminal for and you should see a signal similar to that of Mac and Linux, and if using Windows type: Figure Try waving your arm around near any gem install ruby-serialport electrical equipment and see how this signal changes.
If you are using Mac or Linux, enter: As well as showing the waveform, the window contains a small box with a number in it. This is sudo gem install ruby-serialport the number of samples per second. Each sample represents one pixel across the window, and the If everything has worked okay, you should see a window is pixels wide.
A sample rate of message like this: samples per second means that each sample has a Building native extensions. The wavelength in Figure is serialport If you do this, the sound produced is Figure , has a resolution of one pixel per rough and grating. This is called a square wave. To sample step, there being steps.
So if you produce a more pleasing tone, you need a signal that connect the two test leads together, you should see is more like a sine wave see Figure This Generating a sine wave requires a little bit of corresponds to 0V and is pixels from the top thought and effort.
A first idea may be to use the of the screen, as the window is pixels high. However, the problem is that the analog of the window, the amplitude of the signal is about outputs from an Arduino are not true analog 3V peak to peak.
In fact, their switching frequency is at an quite a lot, something that reinforces that this is the audio frequency, so without a lot of care, our crudest of oscilloscopes and should not be relied signal will sound as bad as a square wave. A better way is to use a digital-to-analog To alter the timebase, change the value in the converter, or DAC as they are known.
A DAC has a delayMicroseconds function. You can generate sounds from an Arduino board by Figure shows a DAC made from what is just turning one of its pins on and off at the right called an R-2R resistor ladder. Figure Square and sine waves. Each of the digital inputs will be connected to an Arduino digital output. The four digits represent the four bits of the digital number. So this gives us 16 different analog outputs, as shown in Table Project 19 Tune Player This project will play a series of musical notes through a miniature loudspeaker using a DAC to approximate a sine wave.
If not, you 0 1 1 1 7 will either have to solder short lengths of solid- core wire to the terminals or, if you do not have 1 0 0 0 8 access to a soldering iron, carefully twist some 1 0 0 1 9 wires round the terminals. To try and keep the number of components to a minimum, we have used an integrated circuit to amplify the signal and drive the loudspeaker.
Theses Figure shows the schematic diagram for values are shown plotted on a chart in Figure Project 19 and the breadboard layout is shown in It is not the smoothest sine wave in the world, but Figure C1 is used to link the output of the ADC to the input of the amplifier, and C2 is used as a The playNote function is the key to generating decoupling capacitor that shunts any noise on the the note.
The pitch of the note generated is power lines to ground. This should be positioned controlled by the delay after each step of the signal. The loop to write out the waveform is itself inside a loop that writes out a number of cycles sufficient to R9 and the variable resistor R10 form a make each note about the same duration.
The notation works as follows. The note, just repeat the note letter without putting a main loop looks at each letter in the song variable space in between. When the whole song is played, there You will have noticed that the quality is not is a pause of five seconds and then the song begins great. It is still a lot less nasty than using a square again. We want to eliminate all that uses two light sensors LDRs : one that traces of the PWM pulses so we can pass the controls the pitch of the sound, the other to control output through a low-pass filter consisting of R11 the volume.
This is inspired by the Theremin and C3. This allows only slow changes in the musical instrument that is played by mysteriously signal to get past. One way to think of this is to waving your hands about between two antennae. In pretend that the capacitor C3 is a bucket that is actual fact, this project produces a sound more like filled with charge from resistor R Rapid a bagpipe than a harp, but it is quite fun.
Arduino Diecimila or Duemilanove board or clone 1 The LDRs, R14 and R15, are positioned at C1 nF un-polarized 20 opposite ends of the breadboard to make it easier to play the instrument with two hands. Similarly, the volume voltage is set by resistor 11 reading the value of analog input 1, scaling it using R14, R15 LDR 19 map, and then writing it out to PWM output 6.
If not, you will either have to solder short lengths of solid- core wire to the terminals or, if you do not have access to a soldering iron, carefully twist some solid-core wires round the terminals. Light harp. Interesting effects can be achieved by meter. In normal mode, the bar graph just flickers waving your hands over the LDRs. In Note that you may need to tweak the values in maximum mode, the bar graph registers the the map functions in the sketch, depending on the maximum value and lights that LED, so the sound ambient light.
VU meter. These are each Duemilanove board or driven through a current-limiting resistor. C1 nF 20 The breadboard layout is shown in Figure This is also used in the loop function, where we iterate over each LED deciding whether to turn it on or off.
For this and 9, which will be the top LED to be lit. This prevents the two reset the maximum value to 0 and then delay for bottom-most LEDs being permanently lit due to milliseconds to prevent keyboard bounce from the transistor bias. It is actually more complicated than that In the next chapter we go on to look at how we use because we also should display that LED if we are an Arduino board to control power—a topic always in peak mode and that LED happens to be the close to the heart of the Evil Genius.
In essence, that means turning things on really know what they are doing and exercise and off and controlling their speed. This mostly extreme caution. Mains electricity is very applies to motors and lasers and the long-awaited dangerous and kills about people a year in the Servo-Controlled Laser project. United States alone. Many more suffer painful and damaging burns.
Relays are D2 1N 38 old-fashioned electromagnetic components that T1 BC 40 activate a mechanical switch when a current flows 5V relay 61 through a coil of wire. First, they can switch high currents Header pin strip 55 and voltages, making them suitable for controlling mains equipment. They also electrically isolate the control side the coil from the switching side so that the high and low voltages never meet, which is definitely a good thing.
The LCD module is connected up in exactly the same way as Project The rotary encoder is also The breadboard layout for the project is quite connected up in the same way as previous projects.
The relay will require about 70 mA, which is a bit too much for an Arduino output to handle Check your datasheet for the relay, as the unaided, so we use an NPN transistor to increase connection pins can be quite counterintuitive and the current. You will also notice that a diode is there are several pin layouts, and your layout may connected in parallel with the relay coil. This is to not be the same as the relay that the author used.
The sudden collapse of the magnetic field in the You can also use a multimeter to find the coil coil generates a voltage that can be high enough to connections by putting it on resistance mode. They damage the electronics if the diode is not there to will be the only pair of pins with a resistance of 40 effectively short it out if it occurs.
Software project for use of the rotary encoder see Listing Project Similarly, as the system. When the temperature falls below the set temperature falls, the power is not reapplied the point, the power is turned on and the room heats moment it falls below the set point, but only when until it is above the set point, and then the room it falls below the set point minus the hysteresis cools until the temperature is below the set point value.
This may take a little time to happen, continuously, as any tiny changes in the reading but when the temperature is just balanced at the would result in the display flickering wildly. So switch-over temperature, this hunting can be frequent. High-frequency switching like this is undesirable because turning things on and off tends to wear them out. This is true of relays as well. One way to minimize this effect is to introduce something called hysteresis, and you may have noticed a variable called hysteresis in the sketch that is set to a value of 0.
Figure shows how we use a hysteresis value to prevent high-frequency hunting. As the temperature rises with the power on, it approaches the set point. However, it does not turn off the power until it has exceeded the set point Figure Hysteresis in control systems. This To test the project, turn the rotary encoder, setting still means it will update three or four times per the set temperature to slightly above the actual second.
To do this, we use the technique of having temperature. The LED should be on. Then put your a counter variable that we increment each time finger onto the thermistor to warm it up. If all is round the loop. When it gets to , we update well, then when the set temperature is exceeded, the display and reset the counter to 0. So we You can also test the operation of the relay by simply write the new temperatures on top of the connecting a multimeter in continuity test beep old temperatures.
This is why we pad the mode to the switched output leads. Second, be very careful and check and double- Putting It All Together check what you are doing. Mains electricity kills. Load the completed sketch for Project 22 from You must only test the relay with low voltage your Arduino Sketchbook and download it to the unless you are going to make a proper soldered board see Chapter 1.
LCD thermostat. One handy part to reclaim from a dead PC is the case fan Figure We are going to use one of Hardware these fans to keep ourselves cool in the summer. Since these computer fans are our computer. Computer-controlled fan. There are so few components in this project that you could twist a few wires together and fit them directly into the Arduino board, thus doing away with the breadboard altogether.
To do this requires four switches or transistors. Figure shows how this works, using M switches in an arrangement that is, for obvious reasons, called an H-bridge. This allows current to flow through the —V motor with terminal A being positive and terminal B Figure An H-bridge. If we were to reverse the switches so that S2 and S3 are closed and S1 and S4 are open, then B will be positive and A will be negative and Project 24 the motor will turn in the opposite direction.
That is, if by some chance S1 and S2 things. This project see Figure takes are both closed, then the positive supply will be complete control of a motor to not only control its directly connected to the negative supply and we speed, but also to make it turn clockwise and will have a short-circuit. The same is true if S3 and counterclockwise. Attached to the motor will be a S4 are both closed at the same time.
The hypnotizer. It uses a standard H-bridge Arduino Diecimila or Duemilanove board or clone 1 arrangement. FQP33N10 43 rather than bipolar transistors for the main power control. An turns on, T2 will turn on with it. In this case, we could do without these transistors and drive the gates of T1 and T3 directly from the Arduino board.
However, to do this, the logic would be inverted high at the gate would turn the transistor off. We could cope with this in the software, but the other reason for using these two additional components is that with them, we could use this circuit to control higher voltage motors, simply by using a higher positive supply voltage.
Software Figure shows the breadboard layout for the The key thing about this sketch Listing Project project. If this happens, there You may decide to photocopy Figure , cut it will be a burning smell and something somewhere out, and stick it to the fan. Alternatively, a more will fizzle and die. This makes the disk milliseconds. The angle that the servo maintains is spin faster and faster in one direction, and then determined by the pulse width.
A pulse width of slow until it eventually reverses direction and then 1. A pulse of 1. You may need to adjust this array for your normally swing it round to degrees, and a particular motor.
The speeds you will need to shorter pulse of 1. You can test each path using it. It is not high-powered, only wires that go to digital pins 5 and 6 to ground. To do so could should turn one way. Connect that lead back to cause retina damage.
Servo-controlled laser. Hardware some of the wire from the laser to the arm to prevent strain on the wire where it emerges from The schematic diagram for the project is shown in the laser. You can do this by putting a loop of Figure It is all quite simple. The servos have solid-core wire through two holes in the server arm just three leads. For each servo, the brown lead is and twisting it round the lead. The servos are terminated in sockets designed to fit You now need to attach the bottom servo to a over a pin header.
Solid-core wire can be used to box or something that will provide support. In connect these to the breadboard. Figure , you can see how it is attached to an old project box. Make sure you understand how The laser diode is driven just like an ordinary the servo will move before you glue the bottom LED from D4 via a current-limiting resistor.
One of the servos is place. Once you are sure everything is in the right glued onto one of these arms see Figure Then the arm is attached to the servo. Do not fit You can see how the breadboard is used to the retaining screw yet, as you will need to adjust anchor the various wires in Figure There are the angle. Glue the laser diode to a second arm and no components except the resistor on the attach that to the servo. It is a good idea to fix breadboard. Software issuing our evil project with coordinates at which to aim the laser.
Fortunately for us, a servo library comes with the Arduino library, so all we need to do is tell each To do this, we allow commands to be sent over servo what angle to set itself at. There is obviously USB. The commands are in the form of letters. For finer movements, r, l, u, and d move the laser by just one degree. To pause and allow the laser to finish moving, you can send the — dash character.
See Project Listing There are three other commands. The letter c will center the laser back at its resting position, and the commands 1 and 0 turn the laser on and off, respectively. Figure Servo and laser assembly. You should see the laser trace shown in Figures and We have also project. The bottom servo can be glued in place on learned how to control the power to motors and to one edge of the board.
The pin headers are use relays. This covers nearly everything we are soldered in place near the 5V and GND lines that likely to want to do with our Arduino board, so in run down the center of the shield so that they can the next chapter, we can put all these things be connected easily to the positive and negative together to create some wider-ranging projects. Figure Servo laser shield.
Figure Bottom side of the servo laser shield. They do not illustrate any particular response. As a person becomes nervous—for point except that Arduino projects are great fun to example, when telling a lie—their skin resistance make. We can measure this resistance using an analog input and use an LED and buzzer to indicate an untruth.
Project 26 We use a multicolor LED that will display red Lie Detector to indicate a lie, green to indicate a truth, and blue to show that the lie detector should be adjusted by How can an Evil Genius be sure that their twiddling the variable resistor.
By using a lie detector, of course. This lie detector see Figure Figure Project Lie detector. This project uses the same multicolor LED as There are two types of piezobuzzers. Some are Project In this case, however, we are not going just a piezoelectric transducer, while some also to blend different colors but just turn one of the include the electronic oscillator to drive them.
In LEDs on at a time to display red, green, or blue. Then turn the setColor red ; knob on the variable resistor until the LED turns beep ; green. Magnetic door lock. When powered, the solenoid will strongly Hardware attract the metal slug in its center, pulling it into The schematic diagram see Figure and place. When the power is removed, it is free to breadboard layout see Figure are much the move.
Like relays, the solenoid is an If the solenoid can be mounted on the inductive load and therefore liable to generate a breadboard, this is all well and good. If not, you back EMF, which diode D3 protects against. The software for this project is, as you would We are using a very low power solenoid, and expect, similar to that of Project 10 see Project this would not keep intruders out of the Evil Listing If you are using a more substantial solenoid, a BD transistor would be better.
We use this information to create a better experience for all users. Please review the types of cookies we use below. These cookies allow you to explore OverDrive services and use our core features. Without these cookies, we can't provide services to you. Search Search for:.