This project is a phone controlled marble tilt maze.
This project utilizes the gyroscope in a phone and multiple servo motors to control a marble tilting maze.
Engineer | School | Area of Interest | Grade |
---|---|---|---|
Ryker V | The Nueva School | Mechanical Engineering | Incoming Junior |
My third and final presentation was a modification to my base project. Although I did not completely finalize this mod, I was able to get all of the code and wiring done. The intention of this mod was to signify using LEDs when the player has finished the tilt maze. I accomplished this by using an IR sensor that initiates a blinking led when activated.
My second milestone within this project was project was finishing the base requirements. I started by using the MIT app inventor to create an android app that determined the orientation of the phone, and sent it via bluetooth to the ESP32. I subsequently designed code on the arduino ide to receive this signal and interpret it accordingly. Although I had many bugs in my initial rendition, I revised many times, effectively eliminated most issues.
My first milestone in this project was designing my tilt maze and my servo circuit. Although my initial plan was to create the maze out of cardboard and other low quality materials, I decided to attempt to construct it with legos. This provided me with both additional stability while building, and unique parts that helped immensely with the design. Along with the maze itself, I also designed a circuit similar to the one I will eventually use. I utilized the sample “knob” code for controlling a servo with a potentiometer and adapted it to two servos with two potentiometers. Understanding this relationship is vital, as my project also requires two servos working together.
Although I initially assumed this project to be exeedingly difficult, I now understand that through research and help from instructors, difficulty is rendered irrelevant. Many of the issues that presented themselves within the scope of this project were amendable by conducting simple research on the internet. I encountered many problems while engaged with this project; every issue I ran into provided me with an opportunity to practice these research skills. This year of Bluestamp Engineering has not only provided me with my first large engineering project, but it has also taught me the fundemental research mindset required for all subsequent projects.
//This example code is in the Public Domain (or CC0 licensed, at your option.) //This example creates a bridge between Serial and Classical Bluetooth (SPP) //and also demonstrate that SerialBT have the same functionalities of a normal Serial #include "BluetoothSerial.h" #include <ESP32Servo.h> #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it #endif BluetoothSerial SerialBT; const int servoPinRoll = 18; const int servoPinPitch = 19; char incomingNum; float updatedInt; String message = ""; float posPitch; float posRoll; Servo servoPitch; Servo servoRoll; void setup() { Serial.begin(115200); SerialBT.begin("ESP32test"); //Bluetooth device name Serial.println("The device started, now you can pair it with bluetooth!"); ESP32PWM::allocateTimer(0); ESP32PWM::allocateTimer(1); ESP32PWM::allocateTimer(2); ESP32PWM::allocateTimer(3); servoRoll.setPeriodHertz(50);// Standard 50hz servo servoPitch.setPeriodHertz(50); servoRoll.attach(servoPinRoll, 500, 2400); servoPitch.attach(servoPinPitch, 500, 2400); servoRoll.write(90); servoPitch.write(90); } void loop() { if (SerialBT.available()) { char incomingNum = SerialBT.read(); message += String(incomingNum); if(incomingNum == 'a'){ posPitch = message.toFloat(); posPitch = posPitch + 90; message = ""; servoPitch.write(posPitch); Serial.println("Pos Pitch: "); Serial.println(posPitch); } if(incomingNum == 'b'){ posRoll = message.toFloat(); posRoll = posRoll + 90; message = ""; servoRoll.write(posRoll); Serial.println("Pos Roll: "); Serial.println(posRoll); } // Serial.println("message: "); // Serial.println(message); // SerialBT.println(incomingNum);// write on BT app // Serial.println("Char: "); // Serial.println(incomingNum);//print on serial monitor } }