Introduction: The Marble Maze Runner
This Instructable will try and help you learn how to make your own Marble tilt Maze
Step 1: The Materials
- Arduino Uno
- Wires x 8 (diffirent colors, see building.)
- Bluetooth Serial Module
- Servo Motor
- Servo Motor Horns x 2 (You can 3D print these)
- Bread Board
- Screws and nuts (To hold the Servo Motor in place)
- Hot glue Gun* (*Only if you are going to make a prototype first, or if you want to make the maze out of cardboard first)
- Something light to make the whole thing out of (Cardboard can work, but it might break easily so you can use it as a prototype. We used aluminum for our final project, and it is cheap and light weight, perfect for the motors)
Safe places you can buy some of these things from:
Step 2: Code
*You need the Arduino application
*You will also need the App SensoDuino
Assuming you got the Arduino application as well as everything else needed in step one, you are going to connect your Ardunio to your computer and upload the code. (If you don't know how to do that you can click HERE to find out how.)
We used this code:
<p>#include <br></p><p>#define START_CMD_CHAR '>' #define END_CMD_CHAR '\n' #define DIV_CMD_CHAR ','</p><p>#define DEBUG 1 // Set to 0 if you don't want serial output of sensor data</p><p>// Create servo objects Servo panServo; Servo tiltServo;</p><p>// starting the motors in the center int tiltVal = 90; int panVal =90; </p><p>// sensoduino values String inText; float value0, value1, value2;</p><p>void setup() {</p><p> // Attach servo objects to Arduino pins panServo.attach(9); tiltServo.attach(10);</p><p> Serial.begin(9600); // The default speed of the HC-05 Bluetooth serial modules Serial.println("\nSensoDuino 0.18 by TechBitar.com (2013).\n"); Serial.println("Android Sensor Type No: "); Serial.println("1- ACCELEROMETER (m/s^2 - X,Y,Z)");</p><p> Serial.println("\n\nNOTE: IGNORE VALUES OF 99.99\n\n"); Serial.flush(); }</p><p>void loop() { Serial.flush(); int inCommand = 0; int sensorType = 0; unsigned long logCount = 0L;</p><p> char getChar = ' '; //read serial</p><p> // wait for incoming data if (Serial.available() < 1) return; // if serial empty, return to loop().</p><p> // parse incoming command start flag getChar = Serial.read(); if (getChar != START_CMD_CHAR) return; // if no command start flag, return to loop().</p><p> // parse incoming pin# and value sensorType = Serial.parseInt(); // read sensor typr logCount = Serial.parseInt(); // read total logged sensor readings value0 = Serial.parseFloat(); // 1st sensor value value1 = Serial.parseFloat(); // 2rd sensor value if exists value2 = Serial.parseFloat(); // 3rd sensor value if exists</p><p> // send sensoduino readings to serial monitor/terminal if (DEBUG) { Serial.print("Sensor type: "); Serial.println(sensorType); Serial.print("Sensor log#: "); Serial.println(logCount); Serial.print("Val[0]: "); Serial.println(value0); Serial.print("Val[1]: "); Serial.println(value1); Serial.print("Val[2]: "); Serial.println(value2); Serial.println("-----------------------"); delay(10); }</p><p>// Set sensor to Accelerometer // sensorType 1 is the Accelerometer sensor</p><p> if (sensorType !=1) return; </p><p> panVal = value0; // value0 = X sensor reading tiltVal = value1; // value1 = Y sensor reading</p><p> tiltVal = map(tiltVal, 10, -10, 0, 179); // Map Accelerometer Y value to tilt servo angle. tiltServo.write(tiltVal); delay(10);</p><p> panVal = map(panVal, -10, 10, 0, 179); // Map Accelerometer X value to pan servo angle. panServo.write(panVal); delay(10); }</p>
Step 3: Connecting the Wires
Once you have that all down and good you are then able to start doing the slightly harder part of placing the wires together. You can either follow the photo or read on to understand how to connect it.
- To power the Arduino need to pug it into a computer through a USB port or have more than 9v of power for the servos we used.
- Run the 5v pin to each of your servos and the Bluetooth module.
- Ground to the servos along with the Bluetooth module.
- Connect the Bluetooth module RX pin to the TX pin on the Arduino, then connect the TX pin on the Bluetooth to the RX on the Arduino.
- Plug your signal wire (the yellow wire) from your servo into pins 9 and 10 on the Arduino.
*Note: It should look like the photos above (besides the electrical tape, we only had that to keep it in place.)
*Note: Each servo is different, look up the order that the wires correspond to. Try and keep the wires the same color to keep track and avoid confusion.
Such as for ours:
- Red = Voltage/Power (VCC)
- Black = Ground (GND)
- White = Signal
Step 4: Building
You can make the whole thing as big and small as you want as long as the motors are able to move and the arduino is somewhat safe.
Step 5: Last Things
We got this instructable idea from: https://www.instructables.com/id/Servo-Controlled-Marble-Maze-Build-2/?ALLSTEPS (you can also go there if we did not explain it well enough for you)