======The Packbot Code, Bluetooth, and Hand Controller Build====== **Author:** Michael Salinas Email: \\ **Date:** Last modified on <07/25/2016> \\ **Keywords:** Lego PackBot, HandController, NXT, BrickxCommander \\ The Hand Controller uses a second NXT brick, connected via Bluetooth, to act as a controller. I found three really good videos on YouTube that can help you better understand how it works. \\ \\ {{youtube>CN3iXGsK9YM?medium}} \\ \\ {{youtube>LlSTK6XSZpw?medium}} \\ \\ {{youtube>On9t-qadpA4?medium}} \\ \\ I also made the code for the packbot in NXC so it is easier to visualize what is going on. \\ Since the code for both the controller and the packbot are relatively short, I will leave it here to be copied and pasted or modified as you please. task main() //The Controller code, or otherwise known as the "master" { string text1,text2,text3; long a, b, c; char x; text1="Left Speed" ; text2= "Right Speed" ; text3= "Flip Speed" ; while(1) { ClearScreen(); a = MotorRotationCount(OUT_A); //Each one of these "Motor Rotation b = MotorRotationCount(OUT_B); //Counts uses the encoders in each c = MotorRotationCount(OUT_C); //motor to obtain their relative //Position TextOut(0,10,text1,DRAW_OPT_NORMAL); //Text on the Screen Displaying TextOut(0,20,text3,DRAW_OPT_NORMAL); //Current position values on the TextOut(0,30,text2,DRAW_OPT_NORMAL); //Controller NumOut(70,10, -a, DRAW_OPT_NORMAL); NumOut(70,20, -b, DRAW_OPT_NORMAL); NumOut(70,30, -c, DRAW_OPT_NORMAL); x = SendRemoteNumber(CONN_BT1,MAILBOX2,a); //Each one of these commands Wait(10); //Sends the data collected x = SendRemoteNumber(CONN_BT1,MAILBOX1,b); //earlier in the code. each Wait(10); //Measured in Milliseconds // motor has a specific mail- x = SendRemoteNumber(CONN_BT1,MAILBOX3,c); //box that corresponds with Wait(10); // A delay between each message being sent. //The PackBot programs' //Mailboxes } } task main() { //This is the Packbot Code long a,b,c,left,right,flip; char x; while(1) //This Program needs to stay on a continuous loop, so that way it { //never stops receiving the messages sent by the controller. Wait(50); //If it refreshes too fast, the packbot is really jerky //If it refreshes too slow, there will be input lag. x = ReceiveRemoteNumber(MAILBOX2, true, a); //RecieveRemoteNumber waits for left = a; //a message to arrive in the OnFwd(OUT_A, left); //corresponding mailbox. x = ReceiveRemoteNumber(MAILBOX1, true, b); flip = b; //The message is then paired OnFwd(OUT_B, flip); //with the corresponding x = ReceiveRemoteNumber(MAILBOX3, true, c); //motor. The values retrieved right = c; //are directly converted to OnFwd(OUT_C, right); //the power value of the } //corresponding motor } **Adjusting wait times within the code can help smooth out the commands given to the packbot. So you can essentially "tune" your controls** \\ You can also have some fun adding sounds when backing up, or possibly adding buttons to the controller that perform other functions. ======The Controller Build====== \\ \\ **Step 1** \\ {{::step1handcontroller.jpg?500|}} \\ **Step 2** \\ {{::step2handcontroller.jpg?500|}} \\ **Step 3** \\ {{::step3handcontroller.jpg?500|}} \\ **Step 4** \\ {{::step4handcontroller.jpg?500|}} \\ **Step 5** \\ {{::step5handcontroller.jpg?500|}} \\ **Step 6** \\ {{::step6handcontroller.jpg?500|}} \\ **Step 7** \\ {{::step7handcontroller.jpg?500|}} \\ **Step 8** \\ {{::step8handcontroller.jpg?500|}} \\ **Step 9** \\ {{::step9handcontroller.jpg?500|}} \\ **Step 10** \\ {{::step10handcontroller.jpg?500|}} \\ **Step 11** \\ {{::step11handcontroller.jpg?500|}} \\ **Step 12** \\ {{::step12handcontroller.jpg?500|}} \\ **Step 13** \\ {{::step13handcontroller.jpg?500|}} \\ **Step 14** \\ {{::step14handcontroller.jpg?500|}} \\ **Step 15** \\ {{::step15handcontroller.jpg?500|}} \\ **Step 16** \\ {{::step16handcontroller.jpg?500|}} \\ **Step 17** \\ {{::step17handcontroller.jpg?500|}} \\ **Step 18** \\ {{::step18handcontroller.jpg?500|}} \\ **Step 19** \\ {{::step19handcontroller.jpg?500|}} \\ **Step 20** \\ {{::step20handcontroller.jpg?500|}} \\ **Step 21** \\ {{::step21handcontroller.jpg?500|}} \\ **Step 22** \\ {{::step22handcontroller.jpg?500|}} \\ **Step 23** \\ {{::step23handcontroller.jpg?500|}} \\ **Step 24** \\ {{::step24handcontroller.jpg?500|}} \\ **Step 25** \\ {{::step25handcontroller.jpg?500|}} \\ **Step 26** \\ {{::step26handcontroller.jpg?500|}} \\ **Step 27** \\ {{::step27handcontroller.jpg?500|}} \\ **Step 28** \\ {{::step28handcontroller.jpg?500|}} \\ **Step 29** \\ {{::step29handcontroller.jpg?500|}} \\ **Step 30** \\ {{::step30handcontroller.jpg?500|}} \\ **Step 31** \\ {{::step31handcontroller.jpg?500|}} \\ **Step 32** \\ {{::step32handcontroller.jpg?500|}} \\ **Step 33** \\ {{::step33handcontroller.jpg?500|}} \\ **Step 34** \\ {{::step34handcontroller.jpg?500|}} \\ **Step 35** \\ {{::step35handcontroller.jpg?500|}} \\ **Step 36** \\ {{::step36handcontroller.jpg?500|}} \\ **Step 37** \\ {{::step37handcontroller.jpg?500|}} \\ **Step 38** \\ {{::step38handcontroller.jpg?500|}} \\ **Step 39** \\ {{::step39handcontroller.jpg?500|}} \\ **Step 40** \\ {{::step40handcontroller.jpg?500|}} \\ **Step 41** \\ {{::step41handcontroller.jpg?500|}} \\ **Step 42** \\ {{::step42handcontroller.jpg?500|}} \\ **Step 43** \\ {{::step43handcontroller.jpg?500|}} \\ **Step 44** \\ {{::step44handcontroller.jpg?500|}} \\ **Step 45** \\ I skipped a few tedious parts to this step. Basically you keep staking the 3 beams to connect the two motors. Do this by using the pins used in step 44 \\ {{::step45handcontroller.jpg?500|}} \\ **Step 46** \\ {{::step46handcontroller.jpg?500|}} \\ **Step 47** \\ {{::step47handcontroller.jpg?500|}} \\ You will actually need to set where the