Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
khianvictory64
Published © MIT

Automatic Dinosaur Game

Presses the keyboard when obstacles are detected.

IntermediateShowcase (no instructions)119
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

Comments