WHAT IT IS ABOUT:
This project is basically an attempt to use python to control devices such as PCDesktop and mobile phones with an arduino board. I am not much experienced in using python with arduino, so as an attempt to understand this combo, I tried this project. I was inspired by the Dino Game project by Jalaal_Mansoori, link below:
WORKING:
This project uses an Infrared proximity sensor as thetouchlesstrigger switch for the Dino's jump(Although most other makers use LDRs for this job).When the IR proximity sensor senses an obstacle it sends this data to the Arduino Micro controller.It then transmits this data to the PC via the USB cable. The command "up" is sent to the python code running in the background. The python code reads the "up" command and then the dinooftheDinoGame on the chrome page jumps by the message sent("up") by the python code to the window.
PYTHON REQUIREMENTS:
I used Spyder present in the Anaconda Navigator. The python application will also do the job.
The python code requires a library called the "pyautogui" which reads the "up" commands and acts accordingly. The package can be downloaded by typing in command prompt
pipinstallpyautogui
Also "pyserial" package is needed for establishing serial communication with Arduino.
This fulfills the requirement of python libraries.
HOW TO START PLAYING :)
The game can be played by using two programs written,in 2 different languages running in harmony. One on the Arduino board(C++) and the other on the PC(Python).The Arduino code needs to be uploaded first to the Arduino board and then executing the python program in the background on the PC while simultaneously playing the game (that's too much of work to do XD ). But don't worry it's super easy. After uploading Arduino sketch keep the Dino game waiting to start on chrome then execute python code;and it's done!!. Then with the first swipe in front of the sensor, the Dino starts running. After this each time when you swipe, the Dino jumps on the screen simultaneously.So, grab the Arduino Board and start playing !!!!
PROJECT TEST RUN VIDEO :)
Click on the Drive link below to view the project execution.Cheers!!!
https://drive.google.com/file/d/1JhNbrqPAMd5ALrHFTAFoj8uWhRGA4q7p/view?usp=sharing
🛠️ เจาะลึกเบื้องหลังการทำงาน (Deep Dive / Technical Analysis)
We've all been there: the internet goes down, and suddenly we're controlling a pixelated T-Rex jumping over obstacles in our browser. The Chrome Dino Game on Arduino brings this addictive experience to a physical device, using an LCD screen as the display and a tactile button as the physical input.
Game Mechanics
Even with limited hardware, this project captures the essence of the original game:
- Scrolling Obstacles: Cacti move from right to left across the bottom row of the 16x2 LCD.
- Jumping: When you press the button, the dino "jumps" to the top row for a set amount of time.
- Collision Detection: If a cactus position overlaps with the dino's position while it's on the bottom row, the game ends.
- Score Tracking: The score increases the longer you survive, displayed right on the screen.
Building the Console
This is a great beginner project because it requires very few parts and uses the LiquidCrystal library, which is a staple of Arduino learning.
Components:
- Arduino Uno: To run the game engine.
- 16x2 I2C LCD: Displays the game graphics.
- Tactile Push Button: The "Jump" controller.
- Jumper Wires: To connect everything together.
Why It's a Great Project
Building a game on an Arduino teaches you about frame rates, non-blocking code (using millis() instead of delay()), and custom character creation for LCDs. Since the 16x2 LCD only has 32 cells, you have to get creative with character maps to draw the dino and the cacti. It's a masterclass in optimization and creative coding!