Project tutorial
Chrome Dino Game "Revamped" with arduino and python

Chrome Dino Game "Revamped" with arduino and python © GPL3+

Use an arduino board to play the chrome no internet dino game without touching your keyboard even once.

  • 1,495 views
  • 1 comment
  • 6 respects

Components and supplies

Apps and online services

Ide web
Arduino IDE
Python 3

About this project

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:

https://create.arduino.cc/projecthub/Jalal_Mansoori/play-dinosaur-game-using-arduino-and-python3-8301cc

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

Code

Arduino_Dino_Game_101Arduino
This is the code you need to upload to Arduino board.
//code by YaSh36.

int IRsensor = A1;
void setup()
{
  Serial.begin(9600);// Making serial monitor ready to be used by python3
  pinMode( LED_BUILTIN, OUTPUT);
  pinMode(A1, INPUT); //  IR sensor is connected to analog pin A1.
}

void loop()
{
  if(analogRead(IRsensor )>500)
  {
    digitalWrite(LED_BUILTIN ,LOW );
  }
  else
  {
     digitalWrite(LED_BUILTIN ,HIGH ); // Otherwise Turn led ON and Sent "up" command to python3 Thats all !
     Serial.println("up");
     delay(250); 
  }
  
}
Python_Dino_Game_101Python
This the code to be used in Python. Make sure you have installed "pyautogui" and "pyserial" prior to execution. Also plaease make sure the 'COM_port' is correctly selected. Mine was COM 4. So, I have written COM4.
#Code by @yash36(Yash Kumar)

import serial
import pyautogui

arduino=serial.Serial('COM4', 9600)

while 1:
    incoming_Data=arduino.readline()
    if 'up' in incoming_Data.decode('utf-8'):  
        pyautogui.press('up')
    incoming_Data="" 

Schematics

Dino_Game_Circuit.
Circuit Schematic for connecting IR sensor to Arduino
Circuit hndbyatt13

Comments

Similar projects you might like

The Chrome Dino Game on an LCD Shield

Project tutorial by Unsigned_Arduino

  • 9,164 views
  • 2 comments
  • 22 respects

Play Dinosaur Game Using Arduino and Python3

Project tutorial by Jalal_Mansoori

  • 2,472 views
  • 1 comment
  • 8 respects

LCD Game

Project showcase by Team Iron_SalsaStudio

  • 17,785 views
  • 16 comments
  • 27 respects

Automated Dino game using arduino

Project tutorial by RAFI RASHEED T C

  • 9,358 views
  • 4 comments
  • 40 respects

Arduino LCD Video Game

Project tutorial by xXarduino_11Xx

  • 6,296 views
  • 3 comments
  • 21 respects

Arduino Pong Game - OLED Display

Project tutorial by Nick Koumaris

  • 14,483 views
  • 3 comments
  • 23 respects
Add projectSign up / Login