' {$STAMP BS2} ' {$PBASIC 2.5} '-------------------------------------Variables-------------------------------------------- Water CON 4 'Water Pump Pin RtHB2 CON 5 '2nd Right H-Bridge Pin RtHB1 CON 6 '1st Right H-Bridge Pin LftHB2 CON 7 '2nd Left H-Bridge Pin LftHB1 CON 8 '1st Left H-Bridge Pin RtIR1 CON 10 'Right IR LED Pin LftIR1 CON 12 'Left IR LED Pin MidIR CON 13 'Middle IR Pin SdrServo CON 14 'Seeding Servo Pin DrlServo CON 15 'Drill Servo Pin RtIR2 VAR Bit 'Right IR Input LftIR2 VAR Bit 'Left IR Input Temp VAR Word 'Temporary For...Next Variable counter VAR Word 'Drill Value Counter Number VAR Word 'IR Turning Value HoldBit VAR Bit 'Middle IR Input counter = 0 'Setting counter to 0 '-------------------------------------Forward Movement------------------------------------- Forward: LOW RtHB1 'Move Right Wheel Forward HIGH RtHB2 LOW LftHB1 'Move Left Wheel Forward HIGH LftHB2 PAUSE 2200 'Time of Forward Movement GOTO MiddleIR Stopping: LOW RtHB2 'Stop Right Wheel LOW LftHB2 'Stop Left Wheel PAUSE 10 'Given Time to Change GOTO Drill '------------------------------------Drill Hole-------------------------------------------- Drill: counter=counter+1 'Increase Counter Value IF counter = 330 THEN Change 'Set Boundry for Counter Value When Desending FOR temp = 0 TO 10 'Drill Rotation per Counter PULSOUT DrlServo,900 'Degree Rotation PAUSE 10 'Time to Activate NEXT GOTO drill Change: counter = 0 'Reset Counter GOTO Up Up: counter=counter+1 'Increase Counter IF counter = 370 THEN Prepare 'Set Boundry for Counter Value When Rising FOR temp = 0 TO 10 'Drill Rotation per Counter PULSOUT DrlServo,200 'Degree Rotation PAUSE 10 'Time To Activate NEXT GOTO Up '-------------------------------Prepare to Release Seeds------------------------------ Prepare: LOW RtHB1 'Move Right Wheel Forward HIGH RtHB2 LOW LftHB1 'Move Left Wheel Forward HIGH LftHB2 PAUSE 1100 'Time of Forward Movement LOW RtHB2 'Stop Right Wheel LOW LftHB2 'Stop Left Wheel PAUSE 10 GOTO Seeder 'Given Time to Change '------------------------------------Release Seeds------------------------------------------ Seeder: FOR temp = 0 TO 10 'Opening Speed PULSOUT SdrServo,900 'Servo Opening Measurement PAUSE 10 'Time to Activate NEXT FOR temp = 0 TO 10 'Closing Speed PULSOUT SdrServo,750 'Servo Closing Measurement PAUSE 10 'Time to Activate NEXT GOTO WaterPump '------------------------------------Water Seeds-------------------------------------------- WaterPump: HIGH Water 'Start Pump PAUSE 750 'Time Pump is Active LOW Water 'Stop Pump PAUSE 100 'Time given to Stop Pump GOTO Repeat '------------------------------------Repeat------------------------------------------------ Repeat: GOTO Forward 'Repeat From Beginning '------------------------------------Turning Movement------------------------------------------ MiddleIR: DIR13=1 'Present Pin 13 Value FREQOUT MidIR,1,38500 'Signal Middle IR Pin,Time to Send,Frequency HoldBit = IN13 'HoldBit is the Input Value if the Middle IR Signal IF HoldBit = 0 THEN GOTO IR 'Checking Objects Ahead GOTO Stopping IR: FREQOUT LftIR1, 1, 38500 'Check Objects to the Left LftIR2 = IN11 IF LftIR2 = 0 THEN Right FREQOUT RtIR1,1,38500 'Check Objects to the Right RtIR2 = IN9 IF RtIR2 = 0 THEN Left IF Number = 1 THEN Left 'Continuing Pattern IF Number = -1 THEN Right Right: Number=Number+1 'Increasing Number Value IF Number=2 THEN stopper 'Limit For Number HIGH RtHB1 'Turn Right Wheel Backward LOW RtHB2 LOW LftHB1 'Turn Left Wheel Forward HIGH LftHB2 PAUSE 2800 'Time For Turning LOW RtHB1 'Turn Right Wheel Forward HIGH RtHB2 LOW LftHB1 'Turn Left Wheel Forward HIGH LftHB2 PAUSE 2200 'Time to Go Forward HIGH RtHB1 'Turn Right Wheel Backward LOW RtHB2 LOW LftHB1 'Turn Left Wheel Backward HIGH LftHB2 PAUSE 2800 'Time For Turning GOTO Forward Left: Number=Number-1 'Decrease Number Value IF Number=-2 THEN stopper 'Limit Number Value LOW RtHB1 'Turn Right Wheel Forward HIGH RtHB2 HIGH LftHB1 'Turn Left Wheel Backward LOW LftHB2 PAUSE 2800 'Time to Turn LOW RtHB1 'Turn Right Wheel Forward HIGH RtHB2 LOW LftHB1 'Turn Left Wheel Forward HIGH LftHB2 PAUSE 2200 'Time to Go Forward LOW RtHB1 'Turn Right Wheel Forward HIGH RtHB2 HIGH LftHB1 'Turn Left Wheel Backward LOW LftHB2 PAUSE 2800 'Time to Turn GOTO Forward stopper: END 'End Program