How to automate the Chrome T-Rex game using Arduino

This post contains the arduino source code and wire connection diagram to reproduce the Chrome Dinosaur automation as shown in the video.


Arduino code

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

int sensorPin = A0;
int sensorValue = 0;

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object

void loop() {
  sensorValue = analogRead(sensorPin);
  Serial.print("value: ");

// compare according to threshld
  if (sensorValue < 200) {
    myservo.write(35); // change according to how much the servo needs to move
    myservo.write(20); // same as above

Or click here to download file with code

Connection diagram