Project

General

Profile

Revision 861

homing works and is added to library

View differences:

homing.c
42 42
#include "serial.h"
43 43

  
44 44
volatile int state = 0;
45
volatile int on = 0;
45 46

  
46 47
void IR_init(void){
47 48
  
......
61 62
  TCCR1A |= _BV(COM1B1)|_BV(COM1B0)|_BV(WGM11);	
62 63
  TCCR1B |= _BV(WGM13)|_BV(WGM12)|_BV(CS10);
63 64
  ICR1 = 0x9C40;
65
  on = 0;
64 66
  
65
  
66 67
}
67 68

  
69
void IR_on(void){
70
	on = 1;
71
}
72

  
73
void IR_off(void){
74
	on = 0;
75
}
76

  
77

  
68 78
ISR(TIMER1_OVF_vect){
69
  state = (state+1)%4;
70
  PORTA |= state;
71
  PORTC &= state + 0xFC;
79
  if(on){
80
	if(state == 7)
81
		state = 0;
82
	else
83
		state++;
84
	
72 85

  
86
	if (state<4)
87
		PORTA ++;
88
	else
89
		PORTA &= 0xFC;
90
  }
91
  else{
92
	PORTA &= 0xFC;
93
  }
94
   
73 95
}

Also available in: Unified diff