void main(void)
{

    usart_init();                        
    adc_init();                                                
    DDRB.3 = 1;


    while (1)
        {        
#if !TEST_MODE
        unsigned int Temperature = read_adc(1);             //Read ADC Channel number 1 (PA1)
        Temperature >>= 1;                                  //Divide the reading by 2 to get the temperature
        printf("Temperature = ");                           //Print the temperature value of the hyper terminal
        printf("%u",Temperature);
        printf("C \n");
        delay_ms(2000);                                     //Wait 2 sec to read the temperature again
        control_motor(Temperature);                         //Control the motor using the Temperature value
#else   
        unsigned int Reading = read_adc(1);                 //Read ADC Channel number 1 (PA1)
        printf("Reading = ");                               //Print the reading
        printf("%d",Reading);
        printf("\n");              
        control_motor_POT(Reading);                         //Control the motor using the Reading value
        delay_ms(100);                                      //Wait 100ms to see the change in motor speed
#endif
        };
}
Ejemplo n.º 2
0
void motorTimerCallback( TimerHandle_t timer){
   // configASSERT(timer);

    // This is called every 500ms and should increment motor control
    // variables that are used to measure speed and distance
    totalMotorRunCounter++;
    control_motor();
}