I simulated this circuit successfully in proteus but it doesn't work on breadboard.
The motor is unipolar stepper motor
I checked the motor and ULN2003A darlington transistor IC.
They work perfectly. Only problem is with the pic. I used a 16f628a
edit 1: programming device detects and programs the PIC. but when i put the PIC on the breadboard it doesnt do anything.
edit 2: programming device is "brenner 8" and software is "USburn"
edit 3: fixed circuit and codes after answers and comments
edit 4: after fixing; only 2 leds are constantly lit and nothing else happened.
edit 5: (May 10th 2019 11:15 hours GMT) it doesnt work no matter what i tried (i tried all answers to this date). Fortunately the teacher gave me a decent grade. I will try with a pickit 3 if i want to try again(currently using a brenner 8).
// CONFIG
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD)
#pragma config BOREN = OFF // Brown-out Detect Enable bit (BOD disabled)
#pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EE Memory Code Protection bit (Data memory code protection off)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
#include <xc.h>
void wait();
void main(void)
{
CMCON = 7;
TRISA = 255;
TRISB = 0;
PORTB = 1;
PORTA = 0;
int portb_value = 1;
int minimum_step_count = 3;
int counter = 0;
wait();
while(1)
{
if(PORTA == 1)
{
while( counter < minimum_step_count )
{
counter++;
if(portb_value != 16)
portb_value=2*portb_value;
if(portb_value == 16)
portb_value=1;
PORTB = portb_value;
wait();
}
counter=0;
}
if(PORTA == 2)
{
while( counter < minimum_step_count )
{
counter++;
if(portb_value == 1)
portb_value=16;
if(portb_value != 1)
portb_value=portb_value/2;
PORTB = portb_value;
wait();
}
counter=0;
}
PORTB = 0;
}
}
void wait()
{
int time = 0;
while( time < 30000 )
{
time++;
}
}