Project tutorial
Arduino playing Dino Game

Arduino playing Dino Game © CC BY

Let an Arduino play Google Chrome's Dino Game

  • 499 views
  • 2 comments
  • 3 respects

Components and supplies

About this project

Is it possible with a few components and a few lines of code to make a machine play a game?

Let's see!

Whenever the LDR Sensor 儭detects a cactus , the Servo-Motor moves and hit the spacebar to let the Dino jump.



Code

Arduino Code to play the Dino GameC/C++
The thresholdValue depends on your ambient light and if you are using Dark Mode or not.
#include <Servo.h>

Servo dinojump;

int sensorPin = A0;    //LDR on A0 
int sensorValue = 0;  
int thresholdValue = 260; //trial and error. 
void setup() {
  Serial.begin(9600);
  dinojump.attach(9);
  dinojump.write(0);
}                        
                                                       
void loop() {
  sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);  //use this to check out your thresholdValue
 
  if(sensorValue >= thresholdValue){   //if obstacle
    Serial.println("jump"); 
    dinojump.write(8);
    delay(200); 
    dinojump.write(0);
  }
  delay(40);                  
}

Schematics

automateddino_steckplatine_sXKkjRmyIN.png
Automateddino steckplatine sxkkjrmyin
Automated Dino
automateddino_3FT0NpDht8.fzz

Comments

Similar projects you might like

The Chrome Dino Game on an LCD Shield

Project tutorial by Unsigned_Arduino

  • 8,417 views
  • 2 comments
  • 21 respects

Automated Dino game using arduino

Project tutorial by RAFI RASHEED T C

  • 3,568 views
  • 4 comments
  • 23 respects

Arduino Pocket Game Console + A-Maze - Maze Game

Project tutorial by Alojz Jakob

  • 12,010 views
  • 8 comments
  • 30 respects

Arduino Dot Matrix Game Console

Project tutorial by Md. Khairul Alam

  • 11,782 views
  • 2 comments
  • 34 respects

Breadboard to PCB Part 1 - Making the Simon Says Game

Project tutorial by Katie Kristoff and Monica Houston

  • 9,660 views
  • 11 comments
  • 32 respects

Pixel Chaser Game

Project tutorial by Unexpected Maker

  • 6,721 views
  • 6 comments
  • 28 respects
Add projectSign up / Login