yashastronomy
Published © GPL3+

Chrome Dino Game "Revamped" with arduino and python

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

BeginnerFull instructions provided5,017
Chrome Dino Game "Revamped" with arduino and python

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
You can also use nano or Mega.
×1
IR proximity sensor
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×3
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1

Software apps and online services

Arduino IDE
Arduino IDE
Python 3

Story

Read more

Schematics

Dino_Game_Circuit.

Circuit Schematic for connecting IR sensor to Arduino

Code

Arduino_Dino_Game_101

Arduino
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_101

Python
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="" 

Credits

yashastronomy

yashastronomy

0 projects • 16 followers

Comments