{"id":596,"date":"2025-10-28T07:44:58","date_gmt":"2025-10-28T05:44:58","guid":{"rendered":"https:\/\/www.hh3dlab.fi\/blog\/?p=596"},"modified":"2025-10-28T07:44:58","modified_gmt":"2025-10-28T05:44:58","slug":"snake-and-pong-games-on-an-esp32","status":"publish","type":"post","link":"https:\/\/www.hh3dlab.fi\/blog\/iot\/snake-and-pong-games-on-an-esp32\/","title":{"rendered":"Snake and Pong games on an ESP32"},"content":{"rendered":"<h1>Introduction<\/h1>\n<p style=\"margin-top: 0;margin-bottom: 0\">Hi, our team is formed with three members Roope Rajahalme, Rasmus Rautakallio and Phong Phan. Before this course our background in programming and electronics was quite basic. We had some experience with Java programming projects but had never worked with displays or games before. We all had deep love for games, so we were curious if it was possible to create a game console on this course.<\/p>\n<h1>Ideas<\/h1>\n<p style=\"margin-top: 0;margin-bottom: 0\">At the start, we brainstormed several project ideas, IoT Plant device, humidity tester, and a retro-style game. We finally decided on Snake game on ESP32 with a TFT screen and joystick controller. We went with these components because course criteria, was to use ESP32 and teacher suggested to use joystick instead of buttons. We decided on retro games because this offered room for creative effects like flashing colours or modifying snake animation also this was challenging enough to keep the project interesting. Creating one small minigame would be too easy and boring, so we decided to add a couple more games to our application. On top of having the snake game, we also made pong game, which is a basic ping pong game where you bounce the ball against walls and it returns it, and lastly we made a memory game, where the game shows inputs in different directions and the player is supposed to replicate the inputs from memory.<\/p>\n<h1>What did we need to learn<\/h1>\n<p style=\"margin-top: 0;margin-bottom: 0\">The initial scope was to build a working Snake game where the player moves a snake with a joystick and eats food while avoiding collisions. We learned many things from this course.<\/p>\n<ul>\n<li>Learning how to program graphics with the Adafruit GFX library and the ST7735 TFT display.<\/li>\n<li>Wiring the joystick and calibrating it to work smoothly.<\/li>\n<li>Wiring ESP32 and TFT LCD screen.<\/li>\n<li>Programming game logic like snake movement, collision detection and scorekeeping.<\/li>\n<\/ul>\n<h1>The building phase<\/h1>\n<p style=\"margin-top: 0;margin-bottom: 0\">Building the game was frustrating and requested a lot of testing and debugging. At first, we tested that every component worked as expected, then we started to add some logic step by step until the game, joystick and LCD Screen worked smoothly. Then we added some graphics like white borders, making snake look more, flashy and food colour change gradually. Lastly, we added two more games \u201cPong\u201d and \u201cMemory game\u201d. We discovered some issues along the way.<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\">For example:<\/p>\n<ul>\n<li>Joystick had to be calibrated many times in order to work smoothly.<\/li>\n<li>Border was disappearing when snake moved along it.<\/li>\n<li>Snake left a piece of itself on the screen every time it ate.<\/li>\n<li>Screen redrawing every time snake move.<\/li>\n<li>The border was pulsing every frame, which made the background distracting.<\/li>\n<li>Snake and Pong game was moving too fast<\/li>\n<li>Trying to apply three games at the same time was difficult.<\/li>\n<\/ul>\n<p style=\"text-align: center;margin-top: 0;margin-bottom: 0\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-599 alignleft\" src=\"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2025\/10\/b7f9bdbb5cfd3042dea94ae15f62ccff.jpeg?resize=640%2C480&#038;ssl=1\" alt=\"\" width=\"640\" height=\"480\" srcset=\"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2025\/10\/b7f9bdbb5cfd3042dea94ae15f62ccff.jpeg?resize=1024%2C768&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2025\/10\/b7f9bdbb5cfd3042dea94ae15f62ccff.jpeg?resize=300%2C225&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2025\/10\/b7f9bdbb5cfd3042dea94ae15f62ccff.jpeg?resize=768%2C576&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2025\/10\/b7f9bdbb5cfd3042dea94ae15f62ccff.jpeg?w=1298&amp;ssl=1 1298w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<h1><\/h1>\n<h1><\/h1>\n<h1><\/h1>\n<h1><\/h1>\n<h1><\/h1>\n<h1><\/h1>\n<h1><\/h1>\n<h1><\/h1>\n<h1>The outcome<\/h1>\n<p style=\"margin-top: 0;margin-bottom: 0\">What we learned from this project was,<\/p>\n<ul>\n<li>How to program and make a structure for the games.<\/li>\n<li>How to create effects and make the game run smoother.<\/li>\n<li>How to wire difference components alone and together with each other.<\/li>\n<li>How to calibrate joystick controller.<\/li>\n<li>How to connect ESP32 to internet.<\/li>\n<li>How to create multiple minigames and combine them into a single working application.<\/li>\n<li>How to send data from our program to a database.<\/li>\n<\/ul>\n<p style=\"margin-top: 0;margin-bottom: 0\">This course definitely made us more interested in tinkering. Now we know more how IoT-devices are built from the scratch, but also now we can see microcontrollers like sensors not only as tools, but these could be implied into game consoles.<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\">In the future we would like to add some sound effects or expanding into a better display and limit test more games to see how far we can go with these components.<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\">This is the program&#8217;s start menu:<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\"><img data-recalc-dims=\"1\" decoding=\"async\" style=\"width: 736px;height: 981px\" src=\"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2025\/10\/f96632a8d2ec6f1d066710dc10801b70.jpeg?w=640&#038;ssl=1\" border=\"0\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\">This is the snake game:<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\"><img data-recalc-dims=\"1\" decoding=\"async\" style=\"width: 654px;height: 871px\" src=\"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2025\/10\/22f81e96f004d1b9d532454fed7fb792.jpeg?w=640&#038;ssl=1\" border=\"0\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\">This is the pingpong game:<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\"><img data-recalc-dims=\"1\" decoding=\"async\" style=\"width: 639px;height: 852px\" src=\"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2025\/10\/28c6c180d10e9159e928dbab1476da7c.jpeg?w=640&#038;ssl=1\" border=\"0\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\">This is the memory game:<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\"><img data-recalc-dims=\"1\" decoding=\"async\" style=\"width: 682px;height: 910px\" src=\"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2025\/10\/2e1e920465d617d96b80d30ef6475771.jpeg?w=640&#038;ssl=1\" border=\"0\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\">This is the game over screen:<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\"><img data-recalc-dims=\"1\" decoding=\"async\" style=\"width: 657px;height: 877px\" src=\"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2025\/10\/5c704b13623a6f7d58938f79616eda03.jpeg?w=640&#038;ssl=1\" border=\"0\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\">This is the game menu screen:<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\"><img data-recalc-dims=\"1\" decoding=\"async\" style=\"width: 598px;height: 797px\" src=\"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2025\/10\/ebe63efe05bb4a0f6463dbe475f50e03.jpeg?w=640&#038;ssl=1\" border=\"0\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\">This is how the data is displayed in a database:<\/p>\n<p style=\"margin-top: 0;margin-bottom: 0\"><img data-recalc-dims=\"1\" decoding=\"async\" style=\"width: 663px;height: 706px\" src=\"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2025\/10\/b021fa3f5e1933cb1d93c8c73e847bf2.jpeg?w=640&#038;ssl=1\" border=\"0\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Hi, our team is formed with three members Roope Rajahalme, Rasmus Rautakallio and Phong Phan. Before this course our background in programming and electronics was quite basic. We had some experience with Java programming projects but had never worked with displays or games before. We all had deep love for games, so we were [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[20,61,15],"tags":[],"class_list":["post-596","post","type-post","status-publish","format-standard","hentry","category-esp32","category-gaming","category-iot"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":268,"url":"https:\/\/www.hh3dlab.fi\/blog\/madrid-2022\/team-5-introduction\/","url_meta":{"origin":596,"position":0},"title":"Team 5 &#8211; Introduction","author":"Madrid Team 5","date":"30.3.2022","format":false,"excerpt":"Hello all, this is an introduction post to Team 5 for Madrid seminar 2022. Our group of students from Haaga-Helia UAS will go to Madrid seminar to teach other students how to build an IoT device that sends GPS, temperature etc. data to the server and displays the information on\u2026","rel":"","context":"In &quot;ESP32&quot;","block_context":{"text":"ESP32","link":"https:\/\/www.hh3dlab.fi\/blog\/category\/esp32\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2022\/03\/IMG_20220328_161500-2-scaled.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2022\/03\/IMG_20220328_161500-2-scaled.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2022\/03\/IMG_20220328_161500-2-scaled.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2022\/03\/IMG_20220328_161500-2-scaled.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2022\/03\/IMG_20220328_161500-2-scaled.jpg?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2022\/03\/IMG_20220328_161500-2-scaled.jpg?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":491,"url":"https:\/\/www.hh3dlab.fi\/blog\/innovation-course\/medication-dispenser-project\/","url_meta":{"origin":596,"position":1},"title":"Medication dispenser project","author":"Heikki Hietala, lab admin","date":"1.6.2023","format":false,"excerpt":"Introduction\u00a0 I have only taken Introduction of Programming course before and basically have no background of coding, neither in 3D printing. This course is a total new experience for me to combine the 3D printing and programming together and the first time to get to know about ESP32 and Arduino.\u00a0\u2026","rel":"","context":"In &quot;Innovation course&quot;","block_context":{"text":"Innovation course","link":"https:\/\/www.hh3dlab.fi\/blog\/category\/innovation-course\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2023\/06\/image-25.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2023\/06\/image-25.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2023\/06\/image-25.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":533,"url":"https:\/\/www.hh3dlab.fi\/blog\/3d-robo-lab\/iot-space-adventure-developing-a-retro-arcade-style-handheld-gaming-device-with-esp32-and-fun-controls\/","url_meta":{"origin":596,"position":2},"title":"IoT Space Adventure: Developing a retro arcade style handheld gaming device with ESP32 and fun controls.","author":"Heikki Hietala, lab admin","date":"16.4.2024","format":false,"excerpt":"Introduction Video demonstration: https:\/\/www.youtube.com\/watch?v=9Bk4u3yt4mI GitHub repository: https:\/\/github.com\/Gianou\/Haaga-Helia-IoT-Experimental-Project Our team consisted of three students: David, Isabelle, and Sara. We have diverse backgrounds and sets of skills within IT. Sara is a second year Business Information Technology student from Haaga-Helia. Her major is in digital services and design, but she studies Front-end\u2026","rel":"","context":"In &quot;3D&quot;","block_context":{"text":"3D","link":"https:\/\/www.hh3dlab.fi\/blog\/category\/3d\/"},"img":{"alt_text":"Idea lists","src":"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2024\/04\/upload-4-205x300.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":508,"url":"https:\/\/www.hh3dlab.fi\/blog\/innovation-course\/508\/","url_meta":{"origin":596,"position":3},"title":"The Data duelist project","author":"Heikki Hietala, lab admin","date":"19.12.2023","format":false,"excerpt":"Introduction Our group members are Jonas Lemstr\u00f6m and Aku Liski. Aku has some experience with blender and 3d printing, and both of us like gaming. Jonas has some experience with game development with Unity. Our prototype is auto-battler that uses Esp32 as platform, Waveshare 7.5 inch E-Paper as screen, few\u2026","rel":"","context":"In &quot;Innovation course&quot;","block_context":{"text":"Innovation course","link":"https:\/\/www.hh3dlab.fi\/blog\/category\/innovation-course\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":550,"url":"https:\/\/www.hh3dlab.fi\/blog\/esp32\/550\/","url_meta":{"origin":596,"position":4},"title":"Air Quality and Control System","author":"Heikki Hietala, lab admin","date":"11.10.2024","format":false,"excerpt":"October 2024 - (c) Stephen Swanson Check it out on GitHub Introduction Hi! I\u2019m Stephen, a 3rd-year student at Haaga-Helia UAS. Programming and creating IoT and embedded devices are recent hobbies of mine, which I picked up in summer 2024 after some friends (Alisa Dunaeva and David Gianadda) suggested I\u2026","rel":"","context":"In &quot;BMP 280 sensor&quot;","block_context":{"text":"BMP 280 sensor","link":"https:\/\/www.hh3dlab.fi\/blog\/category\/bmp-280-sensor\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2024\/10\/Picture2.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2024\/10\/Picture2.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2024\/10\/Picture2.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":643,"url":"https:\/\/www.hh3dlab.fi\/blog\/3d-robo-lab\/643\/","url_meta":{"origin":596,"position":5},"title":"The Smart Gardener \u2013 A Connected Plant Pot","author":"Heikki Hietala, lab admin","date":"20.3.2026","format":false,"excerpt":"By Florent Gilli\u00e9ron, Julien Mignon & L\u00e9on Ehrwein Introduction We are three students taking the IoT Experimental Project - DIG008AS3AE-3004. Our backgrounds are quite different. Florent and Julien had some prior experience with coding and web development and worked with microcontrollers and physical sensors before. L\u00e9on had no experience at\u2026","rel":"","context":"In &quot;3D + Robo Lab&quot;","block_context":{"text":"3D + Robo Lab","link":"https:\/\/www.hh3dlab.fi\/blog\/category\/3d-robo-lab\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2026\/03\/word-image-643-2.jpeg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2026\/03\/word-image-643-2.jpeg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.hh3dlab.fi\/blog\/wp-content\/uploads\/2026\/03\/word-image-643-2.jpeg?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hh3dlab.fi\/blog\/wp-json\/wp\/v2\/posts\/596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hh3dlab.fi\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hh3dlab.fi\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hh3dlab.fi\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hh3dlab.fi\/blog\/wp-json\/wp\/v2\/comments?post=596"}],"version-history":[{"count":5,"href":"https:\/\/www.hh3dlab.fi\/blog\/wp-json\/wp\/v2\/posts\/596\/revisions"}],"predecessor-version":[{"id":611,"href":"https:\/\/www.hh3dlab.fi\/blog\/wp-json\/wp\/v2\/posts\/596\/revisions\/611"}],"wp:attachment":[{"href":"https:\/\/www.hh3dlab.fi\/blog\/wp-json\/wp\/v2\/media?parent=596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hh3dlab.fi\/blog\/wp-json\/wp\/v2\/categories?post=596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hh3dlab.fi\/blog\/wp-json\/wp\/v2\/tags?post=596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}