Translate

vendredi 1 mai 2020

automatic dino game offline

here's a little game made by google chrome when the computer is offline.  thanks to arduino it possible to play it automatically without pressing a key. It based on an arduino uno, a photoresistor(LDR),a 1K resistor, and a servo motor.
The photoresistor detect the light from obstacle which are trees in the game and send to arduino a value different then before, if this value is equal or greater than a defined value in arduino then the servo motor rotates  90 degree and presses the space button on the keyboard for 250 milliseconds, after this the dino jump the obstacle.



This is the schematic

















this is the code below:

#include <Servo.h>
int pot=A0;
int val;
Servo myservo;
void setup() {
  Serial.begin(9600);
  myservo.attach(9);
}

void loop() {
  myservo.write(90);                           
  val=analogRead(pot);
  Serial.println(val);
  if(val>=730){
   myservo.write(0);
   delay(250);
   myservo.write(90);
  }                                                     
}


automatic dino game offline

here's a little game made by google chrome when the computer is offline.  thanks to arduino it possible to play it automatically without...