Temperature Controlled Box – Software

For the code portion of this project, we used Atmel Studio 7 on Windows 10 OS and, per usual, did not experience any interface issues.


Using the ADC handler we were able to monitor the current temperature. Inside this handler we output the current temperature and used if statements to decide whether we needed to turn on the fan or the hair dryer. Inside the second handler we monitored readings of the potentiometer. Before we did this, however, we manipulated the result so that we had the correct desired temp. We divided the result by 1.2, yielding a Fahrenheit scale of +/- 12 degrees from 72, and made sure that any undesirable values we got from the potentiometer when it was turned all the way to either side were removed. The desired temperature was a global variable that was compared in the first ADC handler. IOPORT_CREATE_PIN was used to create and output pin My_LED0, My_LED1, and My_FAN. Pins 17, 16, and 19 were then used to toggle the desired pin the command ioport_set_pin_level (which would be the desired pin; an INT with desired value). Since the enclosure leaked temperature we had to add an offset to the desired temperature so that we could show off the off functionality. To toggle the on-board LEDS we used the commands gpio_set_pin_low() and gpio_set_pin_high() as necessary. For outputting current temperature and the desired temperature on the LCD, we used a char array out_str and snprintf(out_str, OUTPUT_STR_SIZE, “Temperature: %2d F”, last_temperature) so that we could have the string on the screen update with every read of the temperature. Finally, we used gfx_mono_draw_string to actually generate the output on the LCD. The complete program can be found in the source code.