How it Works
Capacitive touch sensing allows detection of human interaction with the circuit without requiring physical touch. The circuit provides some level of detection up to almost a foot away. This detection is accomplished using a modified resistor/capacitor circuit with a single 10 MOhm resistor between two Propeller I/O pins.
The aluminum foil and your body make up the two plates of the capacitor. (Your body also provides some additional resistance and a pseudo ground connection.) The amount of time it takes for the circuit to discharge from a high to a low logic level varies with your proximity to the aluminum foil. But this circuit and code have a twist - we’re using PWM to set a logic level halfway between the Propeller’s high and low values.
Did You Know?
The Pong game is one of the earliest arcade-style video games, originally released in 1972 by Atari. It’s a simple, two-dimensional game in which a player uses a paddle to knock a ball off adjacent walls. Pong has a long history with many adaptations for a variety of hardware consoles and platforms. It is among the simplest games to code.
Wikipedia hosts a complete summary of Pong if you're interested in the full history.
Change the difficulty of the game and add sound effects with a piezo speaker. Test the following:
- There are variables for paddleWidth along with ballSpeedX and ballSpeedY. Increase or decrease these values to change how difficult the game is. For example, a shorter paddle width combined with quicker ball speed will provide more of a challenge.
- Add a small sound or series of sounds that play when the score increments, or when the ball count goes down and when the player scores a point.
- For example, add two new processor blocks with the sound functions inside, then add them to the beginning of the main program. Below are examples of a set of sounds that play from each function “soundGameOver” and “soundScored.”
Try modifying your program to change the colors of the game. Do the colors of the paddle, ball, and walls have an effect on gameplay? Is it easier to see the ball, and therefore more likely to hit it, if it is colored differently from the paddle? What if all game components are the same hue?