Hello,
I’m working on simple project – tempereature sensor based on thermistor. Measured voltage is 0-3,3v and it’s connected to ADC on FRDM KL25Z board (16-bit). So as an output I have 16-bit variable with values 0-65536. Depends on the values, I want to turn on/off led diodes. Code is listed below. I’m using CodeWarrior 10.6
My problem is, that it’s not working as I expected. When temperature is rising, voltage is going down and one LED is turned on, after some time another led is also ON. But when voltage raises back to 3.3v leds are still on. I have to reset my board, then diodes are off. Anyone have an idea what’s wrong with my code?
xQueueHandle queue_led;
void TaskTemp ( void *pvParameters )
{
while(1)
{
queue_led = xQueueCreate( 2, sizeof( uint16_t ) );
uint16_t temp_val;
(void)AD1_Measure(TRUE);
(void)AD1_GetValue16(&temp_val);
xQueueSendToFront(queue_led, &temp_val, 100);
vTaskDelay(100);
}
}
void TaskLed ( void *pvParameters )
{
while(1)
{
uint16_t temp_val;
xQueueReceive(queue_led, &temp_val, 100);
if (temp_val<59000)
{
LED_1_SetVal();
}
else if (temp_val>59000)
{
LED_1_ClrVal();
}
if (temp_val<56000)
{
LED_2_SetVal();
}
else if (temp_val>56000)
{
LED_2_ClrVal();
}
}
vTaskDelete ( NULL );
}
Code in main():
xTaskCreate(TaskLed, (signed char *)"tl", 150, NULL, 1, NULL);
xTaskCreate(TaskTemp, (signed char *)"tt", 150, NULL, 1, NULL);
vTaskStartScheduler();
return(0);