Calibration and Programming

First, we need to calibrate your foil sensors.

  • Once you have wired your board according to the diagrams on the previous page, download the project you just opened to RAM.
  • Log in to your BlocklyProp account and open the official Parallax project Capacitive Touch Calibration.  It should look like this:

The Terminal will display values from the RC time block based on which square of foil your hand is hovering above.

These values may have an extremely large range at first. In the game, you will use the map block, which will do the math and automatically scale and translate these values for you.

Let's try it out and see what happens!

  • Click Load and run (save code to EEPROM). The Terminal will open and begin to display raw sensor values.
  • Hold your hand over the far right area of the foil.
  • Note the values displayed in the Terminal. It will look something like this:

  • Slowly move your hand toward the far left. What do you see happen? Notice that the difference between the first set of values and these are extreme, similar to what you see here:

The example shows values of -260 on the far right and 610 on the far left (yours will probably be different - everything from the size and thickness of the foil squares to the size of your hands, to the humidity in the air, will have an effect). You may need to experiment with these values to finetune the game's performance.

For more information about how the map block works, click here to view it in the reference files.

Record the most extreme values for either side. Now that you have these values, you are ready for the next step.  

  • Open the official complete project, here: Capacitive Touch Pong.
  • Locate the function named “paddleSensor” and find the map block at the end of the function. Change the values shown with the yellow arrows in the image below.

  • Plug in the values you found to be the most extreme on either end when you were adjusting the values with the 0 and 1 placeholders. The map block will do the math and scale these values for you so that the final numbers are between 0 and 85.
  • Save the project into EEPROM and you are ready to test your game!

Your Turn

Give the game a try and see how it works. If it doesn't work quite right, recheck the circuit diagrams and schematics on the first page of this project to be sure your connections are correct.

OLED displays showing the Capacitive Pong Game.