T-Rex Chrome Dino Game using Magicbit
T-Rex Chrome Dino Game
Arduino

T-Rex Chrome Dino Game using Magicbit

Components Required

Introduction

We all have seen the simple game in Google’s Chrome browser that we can access only when there is no internet connection. In this tutorial we will learn about how to automate t-rex chrome Dino game with Magicbit dev. board with Arduino IDE

What You Need

  •  Magicbit
  • LDR (Photo Resistor )
  • Servo Motor
  • Jumper wires

method

Hardware Setup

For this project we mainly used three hardware components. They are Magicbit, servo motor and LDR (Photo Resistor). The complete circuit diagram is shown below.

Put the LDR on the screen of the laptop.

When dark spot comes in front of the LDR. The LDR sends the signal to Magicbit D33 Pin then Magicbit gives a signal to D26 Pin to active the Servo Motor. And just that is the circuit. it keeps on working again and again.

Code

#include <ESP32Servo.h>
#define threshold 250
#define unpress_angle 70 
#define press_angle 36


Servo myservo;  // create servo object to control a servo
bool trig=true;

void setup() {          
  myservo.attach(26);  // attaches the servo on pin 26 to the servo object
  myservo.write(unpress_angle);   
}

void loop() {

 myservo.write(unpress_angle); // unpress the button
 delay(1);
 if(analogRead(33)< threshold)
 {
  
    myservo.write(press_angle);// press the button
    delay(100 ); // waits 100ms for the servo to reach the position
                      
 }                     
}

Related Posts
Leave a Reply