Question: In this lab, you will make a digital thermometer using the SEN-11931 breakout board as well as the 4-bank seven-segment LED display. Study carefully chapter
In this lab, you will make a digital thermometer using the SEN-11931 breakout board as well as the 4-bank seven-segment LED display.
Study carefully chapter 7 regarding the digital temperature sensor provide in the lab kit, referring to the TMP102 datasheet and SEN-11931 breakout board schematics provided under Week Five course area.
Design the hardware connection of the SEN-11931, reuse the 4-bank 7-segment LED connection from Lab 4 for the mbed to read the temperature from the SEN-11931 and display the temperature in Fahrenheit degrees on the LED display in the format of xxx.x. Build your circuit and include all the required information about your hardware design in your lab report. You will also need to make the decision on whether pull-up resistors are needed.
Based on the hardware you designed, write a code that takes temperature measurement every 5 seconds and display the temperature in Fahrenheit degrees in the format of xxx.x (for example: 098.6 or 104.8) on the 4-bank seven-segment LED display.
Test your digital thermometer and explain your testing process and how you use your test results to confirm that your digital thermometer functions properly.
Syntax (1):
#include "mbed.h"
I2C tempsensor(p9, p10); Serial pc(USBTX, USBRX); BusOut digselect(p20, p19, p15, p13); // bus from MSB to LSB: digit4, digit3, digit2, digit1 BusOut digit(p26, p28, p25, p18, p16, p23, p27, p14); // bus from MSB to LSB: dp, g, f, e, d, c, b, a
const int addr = 0x90; char config_t[3]; char temp_read[2]; float temp;
int main() { config_t[0] = 0x01; config_t[1] = 0x60; config_t[2] = 0xA0; tempsensor.write(addr, config_t, 3); config_t[0] = 0x00; tempsensor.write(addr, config_t, 1); while(1) { wait(5); tempsensor.read(addr, temp_read, 2); temp = 0.0625 * (((temp_read[0] << 8) + temp_read[1]) >> 4); pc.printf("Temp = %.2f degC ", temp);
Syntax (2):
This is an example code:
#include "mbed.h"
const unsigned int DIGIT_0=0xC0; const unsigned int DIGIT_1=0xF9; const unsigned int DIGIT_2=0xA4; const unsigned int DIGIT_3=0xB0; const unsigned int DIGIT_4=0x99; const unsigned int DIGIT_5=0x92; const unsigned int DIGIT_6=0x82; const unsigned int DIGIT_7=0xF8; const unsigned int DIGIT_8=0x80; const unsigned int DIGIT_9=0x90; const unsigned int DIGIT_PT=0x7F;
//DigitalOut l1l2p(p17); //DigitalOut l1l2n(p24); DigitalOut l3n(p21); DigitalOut l3p(p22); BusOut l1l2(p17, p24); BusOut digselect(p20, p19, p15, p13); BusOut digit(p26, p11, p25, p18, p16, p23, p12, p14); unsigned int segDriveDigit(unsigned int digit_in); unsigned int display1min(unsigned int hour, unsigned int min); int main(){ while(1) { unsigned int myHour = 0; unsigned int myMin = 0; for (myMin = 0; myMin < 1440; myMin++) { myHour = myMin/60; display1min(myHour, myMin%60); } } }
unsigned int segDriverDigit(unsigned int digit_in) { int myDigit; int retVal = 0xFF; myDigit = digit_in%10; switch (myDigit){ case 0: retVal = DIGIT_0; break; case 1: retVal = DIGIT_1; break; case 2: retVal = DIGIT_2; break; case 3: retVal = DIGIT_3; break; case 4: retVal = DIGIT_4; break; case 5: retVal = DIGIT_5; break; case 6: retVal = DIGIT_6; break; case 7: retVal = DIGIT_7; break; case 8: retVal = DIGIT_8; break; case 9: retVal = DIGIT_9; break; } return retVal; }
unsigned int display1min(unsigned int hour, unsigned int min) { int s, m; hour = hour % 24; min = min % 60; for (m = 0; m < 120; m++) { l1l2 = !l1l2; for (s = 0; s < 25; s++) { digselect = 0x1; digit = segDriverDigit(hour/10); wait_ms(5); digselect = 0x2; digit = segDriverDigit(hour%10); wait_ms(5); digselect = 0x4; digit = segDriverDigit(min/10); wait_ms(5); digselect = 0x8; digit = segDriverDigit(hour%10); wait_ms(5); } } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
