'Demonstrates a Dios connected to a SN754410 'Set pin to port connections in the init function func main() print "reset" initMC() again: MC_setspeed(255) MC_m1fwd() MC_m2rev() pause 3000 MC_m1rev() MC_m2fwd() pause 3000 MC_setspeed(245) MC_m1fwd() MC_m2rev() pause 3000 MC_m1rev() MC_m2fwd() pause 3000 goto again endfunc 'You must call this function before calling ' The others. You can also change the pinout. func initMC() 'Set up some contstants gconst Enable1 13 'Must be this port with PWM gconst Enable2 4 'Must be this port wih PWM gconst M1InputA 0 gconst M1InputB 1 gconst M2InputA 2 gconst M2InputB 3 'Set port direction output Enable1,M1InputA,M1InputB output Enable2,M2InputA,M2InputB MC_m1stop() MC_m2stop() initPWM(2) PWMcourse(0) PWMperiod(255) MC_setspeed(255) endfunc 'Motor1 forward func MC_m1fwd() high M1InputA low M1InputB endfunc 'Motor1 Reverse func MC_m1rev() low M1InputA high M1InputB endfunc 'Motor2 forward func MC_m2fwd() high M2InputA low M2InputB endfunc 'Motor2 Reverse func MC_m2rev() low M2InputA high M2InputB endfunc 'Motor1 stop func MC_m1stop() low M1InputA low M1InputB endfunc 'Motor2 Stop func MC_m2stop() low M2InputA low M2InputB endfunc func MC_setspeed(value) value.bit(8)=1 value.bit(9)=1 PWM1duty(value) 'Motor 1 speed PWM2duty(value) 'Motor 2 speed endfunc include \lib\DiosHWPWM.lib