Magicbit
Published

T-Rex Chrome Dino Game using Magicbit (ESP32)

In this tutorial we learn about how to automate chrome browser Dino Game with Magicbit

BeginnerProtip469
T-Rex Chrome Dino Game using Magicbit (ESP32)

Things used in this project

Hardware components

Magicbit
×1
LDR (Photo Resistor )
×1
Servo Motor
×1
Jumper wires
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Arduino code of Dino Game based on Magicbit

Arduino
#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
                      
 }                     
}

Credits

Magicbit
57 projects • 35 followers
Magicbit is an integrated development platform based on ESP32 for learning, prototyping, coding, electronics, robotics, IoT and more.
Contact

Comments

Please log in or sign up to comment.