Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Maik Schmidt - Arduino A Quick-Start Guide, 2nd Edition (The Pragmatic Programmers) - 2015.pdf
Скачиваний:
146
Добавлен:
22.03.2016
Размер:
30.47 Mб
Скачать

What If It Doesn’t Work? 59

In this chapter, you completed your first really complex Arduino project. You needed a breadboard, LEDs, buttons, resistors, and wires, and you wrote a nontrivial piece of software to make all the hardware come to life.

More LEDs, Dice, and Cubes

Building binary dice is fun, and it’s an easy project even for beginners. But what about the opposite—reading real dice? Steve Hoefera has built a dice reader using an Arduino, and it’s impressive. He uses five pairs of infrared emitters and receivers to

“scan” a die’s surface. It’s a fairly advanced project, and you can learn a lot from it.

Another interesting project is an LED cube: building a cube consisting of LEDs.b It’s surprisingly difficult to control more than a few LEDs, but you can produce astonishing results.

a.http://grathio.com/2009/08/dice-reader-version-2.html

b.http://www.instructables.com/id/The-4x4x4-LED-cube-Arduino/

In the next chapter, we’ll write an even more sophisticated program for generating Morse code. You’ll also learn how to create your own Arduino libraries that you can easily share with the rest of the world.

What If It Doesn’t Work?

Don’t panic! A lot of things will probably go wrong when you work with breadboards for the first time. The biggest problem usually is that you didn’t connect parts correctly. It takes some time to find the right technique for plugging LEDs, wires, resistors, and buttons into the breadboard. You have

report erratum • discuss

Chapter 3. Building Binary Dice 60

to press firmly but not too hard—otherwise, you’ll bend the connectors, and they won’t fit. It’s usually easier to plug in parts after you’ve shortened the connectors. When cutting the connectors, wear safety glasses to protect your eyes!

While fiddling around with the parts, don’t forget that some of them—LEDs, for example—need a certain direction. Pushbuttons are candidates for potential problems, too. Take a close look at the pushbuttons on page 48 and make sure that you’ve mounted them in the right direction.

Even simple things, such as ordinary wires, can lead to problems, especially if they aren’t the right length. If a wire is too short and might potentially slip out of its socket, replace it immediately. Wires are too cheap to waste your valuable time with unnecessary and annoying debugging sessions.

It might be—although it’s rare—that you actually have a damaged LED. If none of the tricks mentioned helps, try another LED.

Exercises

Binary dice are all very well when you’re playing Monopoly with your geeky friends, but most people prefer more familiar dice. Try turning binary dice into decimal dice with seven LEDs. Arrange the LEDs like the eyes on regular dice.

The 1kΩ resistors we used to protect our LEDs in this chapter are rather big. Read Resistors, on page 241, and replace them with smaller ones, for example 470Ω. Can you see the difference in brightness?

LEDs can be used for more than displaying binary dice results. Provided you have enough LEDs, you can easily build other things, such as a binary clock.3 You already know enough about electronics and Arduino programming to build your own binary clock. Try it or think about other things you could display using a few LEDs.

3.http://www.instructables.com/id/My-Arduino-Binary-Clock/

report erratum • discuss

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]