Pong In Hardware…virtually | Hackaday


We are big fans of Falstad Circuit Simulator. Sure, it’s not perfect, but there’s nothing quite like it when you want to create a simple circuit. But we were blown away when we saw a more or less complete hardware implementation of pong in Falstad. No kidding. Starting with the original diagramsthere are multiple pages that show each subtrack and even a playable subset that you can play the game in your browser.

But wait… you probably noticed that there is no CRT display in the simulator components menu. It’s true, there isn’t. However, you can write JavaScript to interact with a running simulation, so the display is a simple piece of JavaScript that samples signals at predetermined points and draws appropriate pictures. There’s even an audio output for sound effects, although this is built into the simulator.

To illustrate how the display works, watch this excerpt:

// called every timestep, which is 6 nanoseconds of game time.
// we do as little work in here as possible.
function didStep(sim) {
   var c = clk.getVoltage();
   if (c == lastclk)
   if (c>2.5) {
// positive clock transition, increase x
   if (x == 375) {
   x = -80;
   if (sim.getNodeVoltage("VBLANK") > 2.5) {
// if we're in vertical blank, set y to 0
   y = 0;
   clearedY = -1;
   sim.setExtVoltage("PADTRIGGER1", 5);
   sim.setExtVoltage("PADTRIGGER2", 5);

You can see the whole thing by simply viewing the page source in your favorite browser.

Not only is it very informative if you’ve ever wanted to know how something like this works, but it’s also a great illustration of what you can do with the Falstad Simulator and some webpage work. It gives us a lot of ideas. If you’re interested in the Pong circuit itself, we really liked how each page broke down a part of the circuit and explained it with the corresponding simulation.

Don’t forget that you can try out Arduino programs in Falstad. You can even build a simple analog computer.


About Author

Comments are closed.