PRABEEN RAJ
Published © GPL3+

Arduino Maze Game

Best way to kill time in quarantine

BeginnerFull instructions provided1,065
Arduino Maze Game

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×2
Analog joystick (Generic)
×1

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

Circuit Diagram

Code

Arduino Code

C/C++
#include <Servo.h>

Servo myservo1;  // create servo object to control a servo
Servo myservo2;
int potpin1 = A0;  // analog pin used to connect the potentiometer
int potpin2 = A1;
int val;    // variable to read the value from the analog pin

void setup() {
  myservo1.attach(9);
  myservo2.attach(10);// attaches the servo on pin 9 to the servo object
}

void loop() {
  val = analogRead(float(potpin1));            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  myservo1.write(val);                  // sets the servo position according to the scaled value
  delay(15); // waits for the servo to get there

  val = analogRead(float(potpin2));            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  myservo2.write(val);                  // sets the servo position according to the scaled value
  delay(15);

}

Credits

PRABEEN RAJ

PRABEEN RAJ

10 projects • 2 followers

Comments