'------------------------------------------------- ' Name : Arm-voice.bas ' Compiler : PicBasic Pro - MicroEngineering Labs ' Notes : Robot arm / Voice direct 364 '------------------------------------------------- TRISB = %00000000 TRISA = %11111111 DEFINE OSC 4 include "modedefs.bas" Led VAR PORTA.4 Baud CON N2400 Com_In VAR PORTA.0 Com_Out VAR PORTA.1 Control VAR BYTE increment var Byte I var byte S0 VAR BYTE S1 VAR BYTE S2 VAR BYTE S3 VAR BYTE S4 VAR BYTE S5 VAR BYTE S6 VAR BYTE S7 VAR BYTE LOW PORTB.0 LOW PORTB.1 LOW PORTB.2 LOW PORTB.3 LOW PORTB.4 LOW PORTB.5 LOW PORTB.6 LOW PORTB.7 HIGH Led S0 = 127 S1 = 111 S2 = 144 S3 = 65 S4 = 127 S5 = 127 S6 = 127 S7 = 127 increment = 1 control = 11 Start: SERIN Com_In,Baud,7,Set_Pos,[255],Control '----------- Base ----------- if Control = 1 then S0 = S0 - increment If S0 < 40 then S0 = 40 endif if Control = 2 then S0 = S0 + increment If S0 > 230 then S0 = 230 endif '----------- Shoulder ----------- if Control = 3 then S1 = S1 - increment If S1 < 40 then S1 = 40 S2 = 254 - S1 endif if Control = 4 then S1 = S1 + increment If S1 > 230 then S1 = 230 S2 = 254 - S1 endif '----------- Elbow ----------- if Control = 5 then S3 = S3 + increment If S3 > 230 then S3 = 230 endif if Control = 6 then S3 = S3 - increment If S3 < 40 then S3 = 40 endif '----------- Wrist ----------- if Control = 7 then S4 = S4 - increment If S4 < 40 then S4 = 40 S5 = 254 - S4 endif if Control = 8 then S4 = S4 + increment If S4 > 230 then S4 = 230 S5 = 254 - S4 endif '----------- Wrist ----------- if Control = 9 then S6 = S6 + increment If S6 > 230 then S6 = 230 endif if Control = 10 then S6 = S6 - increment If S6 < 40 then S6 = 40 endif '----------- Gripper ----------- if Control = 11 then S7 = S7 - increment If S7 < 10 then S7 = 10 endif if Control = 12 then S7 = S7 + increment If S7 > 230 then S7 = 230 endif Set_Pos: PULSOUT PORTB.0,S0 PULSOUT PORTB.1,S1 PULSOUT PORTB.2,S2 PULSOUT PORTB.3,S3 PULSOUT PORTB.4,S4 PULSOUT PORTB.5,S5 PULSOUT PORTB.6,S6 PULSOUT PORTB.7,S7 Goto start