#include <16f628a.h>
#use delay (clock=4000000)
#fuses INTRC_IO,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,NOMCLR,NOPUT,NOCPD
#byte PORTB = 6
#byte CMCON = 0x1F
#use standard_io(A)
// configuracio
void setup(void);
void loop(void);
void main(void) {
setup();
delay_ms(1000);
loop();
}
void setup(void) {
setup_oscillator(OSC_4MHZ);
CMCON = 0x07;
set_tris_a(0x00);
set_tris_b(0x00);
output_b(0x00);
}
void loop(void) {
while (1) {
output_high(PIN_B0); // turn the
output_low(PIN_B1); // motor RIGHT
delay_ms(2000); // wait 2 seconds
output_low(PIN_B0); // turn the
output_low(PIN_B1); // motor OFF
delay_ms(10); // wait 10 ms to stabilise
output_low(PIN_B0); // turn the
output_high(PIN_B1); // motor LEFT
delay_ms(2000);
output_low(PIN_B0); // turn the
output_low(PIN_B1); // motor OFF
delay_ms(10); // wait 10 ms to stabilise
}
}