How to automate the Chrome T-Rex game using Arduino

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



About Low End Guru 22 Articles
Life long technology enthusiast. Expert in software quality assurance, Fan of the maker movement.