'------------------------------------------------------ ' Name : Limit-switch.bas ' Compiler : PicBasic Pro MicroEngineering Labs ' Notes : Program to monitor the status of the leg ' : position limit switches and turn on the ' : corresponding LED when triggered '------------------------------------------------------ ' set porta to inputs trisa = %11111111 ' set portb pins 2 & 3 to inputs trisb = %00001100 '------------------------------------------------------ ' initialize variables servo_pos_l VAR BYTE servo_pos_r VAR BYTE timer1 VAR BYTE timer2 VAR BYTE timer3 VAR BYTE temp1 VAR BYTE servo_r VAR PORTB.5 servo_l VAR PORTB.6 switch_r VAR PORTA.4 switch_l VAR PORTA.3 led_l VAR PORTB.1 led_r VAR PORTB.0 piezo VAR PORTB.4 low servo_l low servo_r '------------------------------------------------------ start: for temp1 = 1 to 5 SOUND piezo, [80,4,100,2] low led_l low led_r pause 50 high led_l high led_r next temp1 SOUND piezo, [100,4,120,2,80,2,90,2] low led_l low led_r right: if switch_r = 1 then high led_r else low led_r endif left: if switch_l = 1 then high led_l else low led_l endif goto right end