up until now I never found a use for "swap" this makes even smaller and more elegant code
Code:'* Name : UNTITLED.BAS * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 29/11/2014 * '* Version : 1.0 * '* Notes : * '* : pic12f1822 * '**************************************************************** #CONFIG cfg1 = _FOSC_INTOSC cfg1&= _WDTE_ON cfg1&= _PWRTE_OFF cfg1&= _MCLRE_ON cfg1&= _CP_OFF cfg1&= _CPD_OFF cfg1&= _BOREN_ON cfg1&= _CLKOUTEN_OFF cfg1&= _IESO_ON cfg1&= _FCMEN_ON __CONFIG _CONFIG1, cfg1 cfg2 = _WRT_OFF cfg2&= _PLLEN_OFF cfg2&= _STVREN_ON cfg2&= _BORV_19 cfg2&= _LVP_OFF __CONFIG _CONFIG2, cfg2 #ENDCONFIG osccon=$6a '4 mhz anselA=0 trisa=000 a var byte b var byte c var byte d var byte pin_mode var bit x var byte all_off var byte pins_on var byte a=1 ;portb.0 b=2 ;portb.1 c=4 ;portb.2 d=16 ;portb.4 pin_mode=0 all_off=!(a+b+c+d) lata = lata & all_off action: pins_on=a+b for x = 1 to 5 lata = lata | pins_on pause 200 lata = lata & all_off pause 200 next x pins_on=c+d for x = 1 to 5 lata = lata | pins_on pause 200 lata = lata & all_off pause 200 next x gosub shuffle goto action shuffle : pin_mode =!pin_mode if pin_mode then swap a,d swap b,c else swap a ,c swap b ,d endif return




Bookmarks