'File.......USB3.bs2 [Useless Sensless Box Version 3] 'Purpose....UselessBox Demostration 'Author.....Paul Muzyka @ [ASKMEAKYZUM@Gmail.com] 'Email......PMuzyka@Parallax.com 'Updated....30 JAN 2018 ' {$STAMP BS2} ' {$PBASIC 2.5} '------------[PROGRAM WRITTEN BY ASKME aka P. Muzyka @ PARALLAX.COM\FORUMS]-------------------------------------------------------------- '------------[PLEASE FOLLOW PROGRESS FROM START TO COMPLETION ON PARALLAX'S FORUM]------------------------------------------------------- 'This program was written to control a Useless Box with two standard servo's, two LED's, one vibration device, and one EMIC2. This code will 'be WELL documented for any NEW Programers with little to NO experience..... 'PLEASE READ ALL NOTES !!!!!!! '------------------------------------------[I/O PINS]------------------------------------------------------------------------------------- 'Under [I/O PINS] you can change the pin numbers to meet your needs. Servo_pin CON 12 'I/O Head/standard servo Servo2_pin CON 13 'I/O foot/standard servo Buttn_pin CON 10 'I/O button/switch BLUE/begining of program when swtch is pressed Move_pin CON 11 'I/O for vibrating device Lite_pin CON 14 'I/O for LED to light up angry bird Lite2_pin CON 7 'I/O for LED to light up angry bird Ping_pin CON 15 'I/O for ping sensor Emictx_pin CON 8 'I/O Tx for sending data to the EMIC2 Emicrx_pin CON 9 'I/O Rx for receiving data from the EMIC2 '------------------------------------------[CONSTANTS]------------------------------------------------------------------------------------ Btnspc CON Byte 'work space for BUTTON command. t9600 CON 84 'EMIC2/????????????????????????????????????????????????????????????????????????????????????????????????? emicbaud CON t9600 'EMIC2/sets baud rate for EMIC2 '------------------------------------------[VARIABLES]------------------------------------------------------------------------------------ Temp VAR Word 'Work space for FOR NEXT/SERVO_PIN/SERVO2_PIN/controls both servo's Work space for NEXT foc VAR Nib 'Force foc to be 0..11/Part of BRANCH command. '-------------------------------------------[INI]------------------------------------------------------------------------------------------ start: LOW 10 'sends pin 10 low for the BUTTON command to function correctly. INPUT 10 'sets pin 10 as a input for the BUTTON command. BUTTON 10, 1, 0, 0, Btnspc, 1, Main '[Main] is a label where the program goes when switch is pressed/this will be where the ' REAL program code starts, ENJOY. '-----------------------------------------------[PROGRAM CODE]----------------------------------------------------------------------------- Main: DEBUG "foc: ", DEC1 idx, " " BRANCH foc, [Task_0, Task_1, Task_2, Task_3, Task_4, Task_5, Task_6, Task_7, Task_8, Task_9, Task_10, Task_11] ' branch to task DEBUG "BRANCH target error...", ' ... unless out of range CR, CR Next_Task: foc = foc + 1 // 12 ' force foc to be 0..11 PAUSE 250 GOTO Main Task_0: DEBUG "BRANCHed to Task_0", CR Task_1: DEBUG "BRANCHed to Task_1", CR Task_2: DEBUG "BRANCHed to Task_2", CR Task_3: DEBUG "BRANCHed to Task_3", CR Task_4: DEBUG "BRANCHed to Task_4", CR Task_5: DEBUG "BRANCHed to Task_5", CR Task_6: DEBUG "BRANCHed to Task_6", CR Task_7: DEBUG "BRANCHed to Task_7", CR Task_8: DEBUG "BRANCHed to Task_8", CR Task_9: DEBUG "BRANCHed to Task_9", CR Task_10: DEBUG "BRANCHed to Task_10", CR Task_11: DEBUG "BRANCHed to Task_11", CR Task_12: DEBUG "BRANCHed to Task_12", CR