/********************************************** e-Gizmo PBOT Controller - BT_CONTROLLED.ino This is for controlling the PBOT using Bluetoooth Wireless module via Smartphones. Upload thi sketch and download the app on Google Playtore. Search for "e-Gizmo BT Controlled eBOT". Kindly also follow the screenshot instructions given on the app for pairing the bluetooth device to your phone. Codes by e-Gizmo Mechatronix Central http://www.e-gizmo.net September 26,2019 ************************************************/ #include "eGizmo_PBOT2019.h" #include eGizmo_PBOT2019 PBOT; int SPEED = 250; //Maximum Speed byte INPUT_FROM_ANDROID_APP; void setup() { Serial.begin(9600); PBOT.BEGIN(); } // MAIN PROGRAM void loop() { if (Serial.available() > 0) { INPUT_FROM_ANDROID_APP = Serial.read(); Serial.println(INPUT_FROM_ANDROID_APP); } if (INPUT_FROM_ANDROID_APP==11){ FORWARD(); } if (INPUT_FROM_ANDROID_APP==12){ BACKWARD (); } if (INPUT_FROM_ANDROID_APP==13){ SPIN_LEFT(); } if (INPUT_FROM_ANDROID_APP==14){ SPIN_RIGHT(); } if (INPUT_FROM_ANDROID_APP==0){ STOP (); } if (INPUT_FROM_ANDROID_APP==17){ PBOT.SERVO(1,95); delay(15); } if (INPUT_FROM_ANDROID_APP==18){ // Put your codes here } if (INPUT_FROM_ANDROID_APP==15){ // Put your codes here if (INPUT_FROM_ANDROID_APP==16){ // Put your codes here } } // PRERSET FUNCTIONS void FORWARD() { //Move Forward PBOT.DIRECTION(MOTOR_BOTH, MOTOR_FWD); PBOT.SPEED(MOTOR_BOTH, SPEED); delay(100); } void BACKWARD() { //Reverse PBOT.DIRECTION(MOTOR_BOTH, MOTOR_REV); PBOT.SPEED(MOTOR_BOTH, SPEED); delay(100); } void SPIN_LEFT() { //Extreme Left PBOT.DIRECTION(MOTOR_A,MOTOR_REV); PBOT.DIRECTION(MOTOR_B,MOTOR_FWD); PBOT.SPEED(MOTOR_BOTH, SPEED); delay(100); } void SPIN_RIGHT() { //Extreme Right PBOT.DIRECTION(MOTOR_A, MOTOR_FWD); PBOT.DIRECTION(MOTOR_B, MOTOR_REV); PBOT.SPEED(MOTOR_BOTH, SPEED); delay(100); } void STOP() { PBOT.SPEED(MOTOR_BOTH, 0); }