Hardware Reference
In-Depth Information
Complex Conversations
In the previous project, you controlled the microcontroller from the computer using
a very simple protocol. This time, the microcontroller will control an animation on the
computer. The communications protocol is more complex as well.
Project 2
What the computer does with the mouse's data depends
on the application. For this application, you'll make a small
pink monkey play pong by waving his arms. He'll also have
the capability to reset the game by pressing a button, and
to serve the ball by pressing a second button.
Monski Pong
In this example, you'll make a replacement
for a mouse. If you think about the mouse
as a data object, it looks like Figure 2-11.
Connect long wires to the flex sensors so that you can
sew the sensors into the arms of the monkey without
having the microcontroller in his lap. Use flexible wire; old
telephone cable works well. A couple of feet should be fine
for testing.
MATERIALS
» 2 flex sensor resistors
» 2 momentary switches
» 4 10-kilohm resistors
» 1 solderless breadboard
» 1 Arduino microcontroller module
» 1 personal computer
» All necessary converters to communicate
serially from microcontroller to computer
» 1 small pink monkey
Connect long wires to the buttons as well, and mount
them in a piece of scrap foam-core or cardboard until
you've decided on a final housing for the electronics. Label
the buttons “Reset” and “Serve.” Wire the sensors to the
microcontroller, as shown in Figure 2-12.
Output - 4 values:
- x coordinate, 10 bits
- y coordinate, 10 bits
- button 1, 1 bit
- button 2, 1 bit
1
2
Input:
x movement
Input buttons
Input: y movement
Figure 2-11
The mouse as a
data object.
 
Search WWH ::




Custom Search