Dinosaur Game Hack Google Chrome Games

Spread the love

Dinosaur game (Trex run) is a fun game and can be played with absolutely no internet. The second method to open this game is to put your device on flight mode and open google chrome. Keep pressing the space bar again and again and make Trex jump to save itself from the cactus plant but after some time, you may find it a bit boring. So, let us try a new way to do this. And this time, we will make Dinosaur Game Hack in a totally different way.

Material Required

  • Arduino UNO
  • LDR (light dependent resistor)
  • 10k ohm resistor
  • Servo motor
  • Jumper wires
  • Breadboard
  • USB Cable
  • Google chrome on a PC for Dinosaur Game Hack

LDR (Light Dependent Resistor)

About LDR

LDR is also known as a photoconductor. It is basically a photocell that works on photoconductivity. This resistor’s value is decreased when the intensity of light decreased. This component is used in street light, camera, light beam alarm, etc.

Structure and Working

LDR
LDR Working

The main component for the LDR is Cadmium Sulphide (CdS), that is used as the photoconductor and contains very few electrons when not illuminated. As soon as light falls on the sensor, the electrons are liberated and the conductivity of the material increases. When the light intensity exceeds a certain frequency, the photons absorbed by the semiconductor give band to the electrons. Then, the energy required to jump into the conduction band. This causes the free electrons or holes to conduct electricity and thus dropping the resistance dramatically (< 1 Kiloohm).

R = A.E^a

where E – Illumination (lux)
R – Resistance (Ohms)
A, a – constants

LDR Connection with Arduino

If you use LDR directly with Arduino it may give some floating values. To avoid this, we use a pull-up or pull-down resistance with it. In this trex run, we are using pull-down resistance.

Software ways

Arduino digital pins have in-build pull-down resistance. We can initialize using the software. The Arduino code syntax is:

pinMode(2, INPUT_PULLUP);

Hardware Ways

This method is recommended as you only need a 10k OHM resistance. With the help of a 10k OHM resistance connect input pin and GND. Refer to the image below showing schematics. Source: Wikipedia

LDR
Pull-down resistance connection

Servo motor

A servo motor is a close loop system that allows precise control of angular position. It is a 3 wire system- red, brown, and yellow for supply, GND, and signal.

Servo motor
Servo motor wires

Servo motor with Arduino

The connection of the servo motor with Arduino is very simple. Connect the servo motor’s red wire to Arduino 5v, black wire with GND, and the yellow wire to pin number 9.

Servo wire colorArduino pin number
YellowPin No. 9
Red5v
Brown/BlackGND
Connection table
servo motor with arduino
Connection diagram

Final Connection

The final connection of Google Chrome games is very simple. Connect everything according to the following schematic diagram shown below.

Arduino Pin no.LDRServo motor10k ohm Resistor
A0First LegFirst Leg
9Yellow wire
GNDBlack WireSecond Leg
VCCSecond LedRed wire
Dinosaur Game Hack
final schematic of Dinosaur Game Hack

Installation on the Computer

Step: 1

With the help of a tape, stick LDR facing toward the screen leaving 1cm space from Dino Game.

Dinosaur Game Hack

Step: 2

Again with the help of a tape, stick the Servo motor near the space bar, in such a way that the shaft of the motor hit the space bar.

Step: 3

The final output will look like this, refer the image below.

Coding for Trex Run

#include<Servo.h>

Import Servo motor library.

define LDR A0 //attache LDR data pin to arduino pin no 3
Servo myservo;

Defining analog pin A0 as LDR & Servo as myservo

void setup() {
pinMode(LDR, INPUT);
myservo.attach(9);
Serial.begin(9600);
}

In the void setup function, I am telling I will use LDR(A0) pin for input and my servo will attach to pin no. 9. Also establishing a serial communication at baud rate 9600.

void loop() {
int senseValue = analogRead(LDR);
Serial.println(senseValue);

In loop function we are reading LDR value and assign that value to senseValue variable And display it serial.

if (senseValue > 600)
{
myservo.write(0);
}
else
{
myservo.write(100);
delay(150);
}
}

Here we are making a condition to decide the position of servo. we know that LDR gives value according to light intensity. so it will detect the cactus and write the servo from 0 degree angle to 100 degree angle. which result the space bar will pressed. and Trex will jump

Final code copy and upload on your Arduino board

# include <Servo.h>
define LDR A0 //attache LDR data pin to arduino pin no 3
Servo myservo;
void setup() {
pinMode(LDR, INPUT);
myservo.attach(9);
Serial.begin(9600);
}
void loop() {
int senseValue = analogRead(LDR);
Serial.println(senseValue);
if (senseValue > 600)
{
myservo.write(0);
}
else
{
myservo.write(100);
delay(150);
}
}
Final Product

Add a Comment

Your email address will not be published. Required fields are marked *