Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
khianvictory64
Published © MIT

Automatic Dinosaur Game

Presses the keyboard when obstacles are detected.

IntermediateShowcase (no instructions)121
Automatic Dinosaur Game

Things used in this project

Story

Read more

Schematics

Project Schematic Diagram

Code

Dinosaur Game

C/C++
This code detects if there's an obstacle in the screen.
#include <Servo.h>
Servo sv;
void setup() {
  pinMode(2,OUTPUT);
  pinMode(A0,INPUT);
  Serial.begin(9600);
  sv.attach(9);             
}

void loop() {
  digitalWrite(2,HIGH);  
  Serial.println(analogRead(A0));
  if(analogRead(A0) <= 24) {                                     
    sv.write(75);
    delay(350);
    sv.write(90);
  } else {
    sv.write(90);
  }
}

Credits

khianvictory64
0 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.