Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int PhotoArray[7] = {0,0,0,0,0,0,0};
- //status of each PhotoTransistor stored here
- int TransistorArray[7] = {8,14,6,4,2,0,12};
- //TransistorArray relates the respective ADC/Transistor channel to the index of IRs.
- for(int i = 0; i < 7; i++){
- setIR(i);
- for(int j = 0; j < 1000; j++){} //garbage loop for delay
- PhotoArray[i] = PollIR(TransistorArray[i]);
- trace_printf("%u ", PhotoArray[i]);//in theory I can remove this, not sure what happens in practice.
- if(!PhotoArray[i])//sets display LED when on tape
- setLED(i);
- if(PhotoArray[i])//resets display LED when not on tape
- resetLED(i);
- for(int j = 0; j < 1000; j++){} //garbage loop for delay
- }
- //case: on track, middle 3 transistors read tape
- if(!PhotoArray[2] && !PhotoArray[3] && !PhotoArray[4]){
- //reset reverse pins, L&R motors
- HAL_GPIO_WritePin( GPIOB, GPIO_PIN_4 , GPIO_PIN_RESET );
- HAL_GPIO_WritePin( GPIOE, GPIO_PIN_6 , GPIO_PIN_RESET );
- //set forward pins, L&R motors
- HAL_GPIO_WritePin( GPIOB, GPIO_PIN_6 , GPIO_PIN_SET );
- HAL_GPIO_WritePin( GPIOB, GPIO_PIN_8 , GPIO_PIN_SET );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement