Raspberry Pi Hardware Projects 2
eBook - ePub

Raspberry Pi Hardware Projects 2

Andrew Robinson, Mike Cook

Partager le livre
  1. English
  2. ePUB (adapté aux mobiles)
  3. Disponible sur iOS et Android
eBook - ePub

Raspberry Pi Hardware Projects 2

Andrew Robinson, Mike Cook

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

Raspberry Pi is a UK Non Profit with the goal of creating a new generation of computer programmers. Observing how the UK Tech Industry was kickstarted by the availability in the 1980s of relatively cheap, very programmable computers such as the ZX81, the Commodore and the BBC Micro, the Raspberry Pi Foundation designed a ÂŁ15/$25 computer which encourages the user to play and to learn. Although intended for schools, it has also been adopted by hackers and geeks, and a whole ecosystem of software and hardware is being built around the Pi. With a million boards now sold, the goal of the Foundation is well underway.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Raspberry Pi Hardware Projects 2 est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Raspberry Pi Hardware Projects 2 par Andrew Robinson, Mike Cook en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Hardware. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Éditeur
Wiley
Année
2013
ISBN
9781118588901
Édition
1
Sous-sujet
Hardware
Chapter 1
Computer-Controlled Slot Car Racing
In This Chapter
‱ Learn how to use your Raspberry Pi to enable and disable a slot car set.
‱ See how to make your own illuminated joystick pad.
‱ Discover how to use an external text file as a question bank.
‱ Understand the interactions between the software and hardware.
This project is a rather different twist on the multiple-choice quiz theme. Not only does it have a novel way of inputting answers, but it also has a rather novel way of keeping the score.
The idea is that you are going to hack into a slot car game and allow the Raspberry Pi to control when the game can be played. Then players can drive their cars for three seconds at a time, if they are the first to answer a question correctly. If they get the question wrong, their opponent gets the time. The game continues until one player crosses the finishing line after completing a set number of laps. The questions come from a plain text file and can be added to, or the subject of them changed. They are multiple-choice questions with four possible answers, and players indicate their answer by moving a special joystick button. The successful player’s joystick button will light up green, whereas the other player’s button will light up red.
Obtaining a Slot Car Racer
So how are you going to implement this game? First you need a slot car racing game. These come in all sorts of shapes and sizes, from sleek Formula One racing cars to heavy trucks and even grannies on Zimmer frames. In essence they are very similar: It’s a race between two players. Mostly they are set up so that if you go too fast at the corners, the vehicle will come off the track, so it is not just a matter of running the cars at top speed all the time. Normally the track is some form of figure eight, so the track length can be made the same for both players. Sometimes the two vehicles cross at the same level, giving opportunities for crashes, and other times the tracks go over and under each other. Although there are very expensive racing games, some can be had cheaply in thrift shops or second-hand stores.
Hacking Your Slot Car Racer
You need to hack into your slot car racer, and, as there are lots of different types of them, I can’t be too prescriptive about what you need to do. However, from the electrical point of view, it is basically all the same. What you are going to do is to wire a PiFace relay in series with each hand controller. This will involve cutting one of the two wires coming from the controller, and connecting each end of your cut wire into the NO and common relay connections. NO stands for normally open – this connection is only connected to the common line when the relay is energised; when the relay is not energised, that is the normal state – no electrical connection is made. Figure 1-1 shows how you can do this using a screw connection block. These are the type you use for electrical wiring around the house. They come in various sizes, and the size you want is the smallest, which is often marked something like 3 Amps. A sharp hobby knife can slice the two wires apart, and then you can cut one of them; it doesn’t matter which one. You should cut back the insulation and then, following the diagram, attach each end to two of the connector blocks. Take the other end and run wires off to the PiFace board. Do the same for the other controller. When you want to play with your slot car game normally you simply replace the long wires trailing back to the PiFace board with a simple link. Do this close to the track connections so that you have the maximum length of wire on the hand controllers.
Figure 1-1: Hacking into your slot car racing game.
9781118588925-fg0101.eps
Sometimes the wires coming from the hand controller are all bundled into one cable, so it is impossible to cut just one wire. If this is the case, you will have to cut both of them and join the other wire back up again. This sort of thing is shown in Figure 1-2. In this case the wire consists of an inner conductor and an outer braided wire sheath. Strip back the outer sheath and make sure that no thin strands of wire are shorting out to the other wire. Use insulation tape or heat shrink sleeving to insulate the sheath. Then wire it up as shown in Figure 1-2. Note that this diagram is for one controller; you will have to duplicate this for the other player’s controller.
Figure 1-2: Hacking into your slot car racing game if you can’t cut just a single wire.
9781118588925-fg0102.eps
Testing Your Slot Car Racer Hack
Now you need to test the slot car hack. Power up your slot car racing game as normal and run the program in Listing 1-1.
Listing 1-1 Slot Car Racer Hack Test
#!/usr/bin/env python
"""
Slot Racer Hack tester on the PiFace board
"""
import piface.pfio as pfio # piface library
pfio.init() # initialise pfio
def main():
lastInput =0
print "Slot Racer Hack test press the two input
turnover
switches"
print "on the PiFace board to change who is racing"
print "ctrl - C to quit"
while True :
buttons = pfio.read_input()
if (buttons &am...

Table des matiĂšres