Const PWMmode8bit As Byte = bx0000_0001 Const PWMmode9bit As Byte = bx0000_0010 Const PWMmode10bit As Byte = bx0000_0011 Const PWMmodeOff As Byte = bx0000_0000 Const MaskOC1A As Byte = bx1000_0000 Const MaskOC1B As Byte = bx0010_0000 sub InitMotors() Register.TCCR1A = PWMmode8bit 'configure PWM hardware Register.TCCR1B = 3 'clk / 64 Register.OCR1AH = 0 Register.OCR1AL = 0 Register.OCR1BH = 0 Register.OCR1BL = 0 Call PutPin(26, bxOutputLow) Call PutPin(27, bxOutputLow) Register.TCCR1A = Register.TCCR1A Or MaskOC1A 'start pwm Register.TCCR1A = Register.TCCR1A Or MaskOC1B end sub sub StartMotors() Register.OCR1AH = 0 Register.OCR1AL = 64 '64=1.1ms Register.OCR1BH = 0 Register.OCR1BL = 120 '120=2.0ms end sub sub StopMotors() Register.OCR1AH = 0 Register.OCR1AL = 0 Register.OCR1BH = 0 Register.OCR1BL = 0 end sub sub Backwards() Register.OCR1AH = 0 Register.OCR1AL = 120 Register.OCR1BH = 0 Register.OCR1BL = 64 end sub sub TurnLeft() Register.OCR1AH = 0 Register.OCR1AL = 64 Register.OCR1BH = 0 Register.OCR1BL = 64 end sub sub TurnRight() Register.OCR1AH = 0 Register.OCR1AL = 120 Register.OCR1BH = 0 Register.OCR1BL = 120 end sub