/********************************************** * e-Gizmo PBot2018 Controller - LINEBOT.ino * * This is for Linesensor sample sketch to * follows the black line or white line track. * * Reading the 3channel Line sensors: * Calibration Instructions: * For the new eGizmo PBot Uno Controller features * first thing to do is to calibrate the line * sensors. How to calibrate it? Read the ff. * 1. After uploading your code for linesensors. * Turn OFF the POWER switch. * 2. Place the eGizmo PBot controller to the "black * line" then Press and Hold LINE CAL and SYS RST, * while pressing and holding the buttons, Turn ON * the POWER Switch. LN2 (D12 LED indicator) is ON. * 3. First RELEASE the SYS RST followed by LINE CAL. * Make sure the 3CH Line sensors are faces on the * "black line" and you will see the LN1 and LN3 * (D11 and D13 LED indicators) are * Turn ON and LN1 is blinking. Now Press LINE CAL * once for the white color calibration. * 4. Next, if the L3 (D13 LED indicator) is blinking. * Place the 3CH Line sensors on the "White track". then * Press LINE CAL again once for the black color * calibration. After that you will see all the LEDS * for linesensors are ON. * 5. Now your eGizmo PBot Uno Controller line sensors * are calibrated. Then Press the RESET button. * You can now trace the line and DONE. * * PBot.LS1_LEFT(); * PBot.LS2_CENTER(); * PBot.LS3_RIGHT(); * * Note: * Output reads: * White line detected = 0 or LOW; * Black line detected = 1 or HIGH; * * Codes by * e-Gizmo Mechatronix Central * http://www.e-gizmo.net * March 17,2020 ************************************************/ #include "eGizmo_PBot_Uno.h" #include eGizmo_PBot_Uno PBot; int MotorSpeed = 80; void setup(){ PBot.BEGIN(); PBot.STOP(); } void loop() { if(PBot.LS1_LEFT() == LOW && PBot.LS3_RIGHT() == LOW){ PBot.FORWARD(MotorSpeed); } if(PBot.LS1_LEFT() == LOW && PBot.LS3_RIGHT() == HIGH){ PBot.TURNRIGHT(MotorSpeed); } if(PBot.LS1_LEFT() == HIGH && PBot.LS3_RIGHT() == LOW){ PBot.TURNLEFT(MotorSpeed); } if(PBot.LS1_LEFT() == LOW && PBot.LS2_CENTER() == LOW && PBot.LS3_RIGHT() == LOW){ PBot.REVERSE(MotorSpeed); delay(200); } //UNCOMMENT THIS FOR STOPPING POINT (FINISHED LINE) /* if(PBot.LS1_LEFT() == HIGH && PBot.LS3_RIGHT() == HIGH) { PBot.STOP(); }*/ }