#include "C:\MentorProjects\Camera_Stepper\PIC_CODE\Camera_Stepper.h" // Defines #define RELAIS PIN_C0 #define RICHTING_IMT_1 PIN_A2 #define STAP_IMT_1 PIN_A3 #define RICHTING_IMT_2 PIN_A4 #define STAP_IMT_2 PIN_A5 #define START_STOP PIN_B0 #define LINKSOM PIN_B1 #define RECHTSOM PIN_B2 int1 START = FALSE; int1 STOP = FALSE; int16 MAX_STAP = 1023; #int_EXT void EXT_ISR() { if(START == FALSE)// eertse keer op start_stop gedrukt { START = TRUE; }else { STOP = TRUE; } } void CAMERA_STAP() { int16 i, j; for (j = 0; j < 33; j++) { delay_ms(1000); output_high(RELAIS); delay_ms(250); output_low(RELAIS); for(i = 0; i < MAX_STAP; ++i) { output_low(RICHTING_IMT_1); delay_us (250); output_high (STAP_IMT_1); delay_us (250); output_low (STAP_IMT_1); /* if (STOP == TRUE) { i = MAX_STAP; }*/ } } START = FALSE; STOP = FALSE; } void initSystem(void) { // System initialisation setup_adc_ports(NO_ANALOGS); setup_adc(ADC_OFF); setup_spi(FALSE); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); enable_interrupts(INT_EXT); enable_interrupts(GLOBAL); } void main() { initSystem(); while(1) { if(START)//dan moeten we een rondje gaan draaien..... { CAMERA_STAP(); } if(!(input(LINKSOM))) { output_low(RICHTING_IMT_1); delay_us (250); output_high (STAP_IMT_1); delay_us (250); output_low (STAP_IMT_1); } if(!(input(RECHTSOM))) { output_high(RICHTING_IMT_1); delay_us (250); output_high (STAP_IMT_1); delay_us (250); output_low (STAP_IMT_1); } } }