Sebastian Felix Schwarz
Published © CC BY

Arduino playing Dino Game

Let an Arduino play Google Chrome's Dino Game 🦖🤖

BeginnerFull instructions provided1 hour3,510
Arduino playing Dino Game

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Resistor 10k ohm
Resistor 10k ohm
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1

Story

Read more

Schematics

automateddino_steckplatine_sXKkjRmyIN.png

Automated Dino

Code

Arduino Code to play the Dino Game

C/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);                  
}

Credits

Sebastian Felix Schwarz

Sebastian Felix Schwarz

3 projects • 1 follower
working for over 15y in the digital bussiness, state certified computer science assistant and Mario Kart driver on the SNES ;)

Comments