Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

D esign the digital clock with the capability of digital thermometer upon the push of a push button. Using SEN-11931 and the LCD digital clock

Design the digital clock with the capability of digital thermometer upon the push of a push button. Using SEN-11931 and the LCD digital clock display, Design a way of using the pushbutton to trigger an interrupt to your system. Your system, upon receiving this interrupt, responds by reading and displaying the temperature in Fahrenheit degrees on the LCD display in the format of xxx.x. The system must resume displaying the digital clock. Build your circuit and include all the required information about your hardware design in your lab report.

Based on the hardware you designed, choose an interrupt/timer tool from mbed to update the LCD display with the digital clock HH:MM:SS every second with the correct time of second, minute and hour. You must NOT have any code for counting or displaying the clock display with hour, minute or second in the main() function other than setting the clock display to 00:00:00 at start up. This means, you should use a timing tool (interrupt or timer) to update the clock display rather than using wait(1) for waiting for 1 second.

Whenever the user pushes on the push button and releases it, the system will respond to it by measuring the current temperature and displaying the temperature to the LCD for approximately 1 second. Then the system shall resume the display of the current digital time. Keep in mind, the clock should continue counting as if the temperature reading was never done instead of restarting from 00:00:00.

The below is the digial clock syntax:

#include "mbed.h" #include "TextLCD.h"

TextLCD lcd(p15, p16, p17, p18, p19, p20);

int hours, minutes, seconds;

int main() { hours=0; minutes=0; seconds=0; while(1){ if(seconds==60){ seconds=0; minutes++; } if(minutes==60){ minutes=0; hours++; } if(hours==24){ hours=0; } lcd.locate(0, 1); // row 1, column 0

lcd.printf("%02d:%02d:%02d", hours, minutes, seconds); //to printing the values in lcd seconds++; //second increases after one second wait(1); //wait apply for wait one second

} }

The below is the syntax for SEN-11931 temperature sensor:

#include "mbed.h"

const unsigned int DIGIT_0 = 0xC0; const unsigned int DIGIT_1 = 0xFC; 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 = 0x98; const unsigned int DIGIT_PT = 0x7F; const int TEMP_ADDR = 0x90;

DigitalOut l3n(p21); DigitalOut l3p(p21); BusOut l1l2(p17, p24); BusOut digselect(p20, p19, p15, p13); BusOut digit(p26, p11, p25, p18, p16, p23, p12, p14); unsigned int segDriverDigit(unsigned int digit_in); unsigned int display5sec(float temp); I2C tempsensor(p9, p10); Serial pc(USBTX, USBRX); // print temperature on console char config_t[3]; char temp_read[2];

int main() { float temp_reading; config_t[0] = 0x01; config_t[1] = 0x60; config_t[2] = 0xA0; tempsensor.write(TEMP_ADDR, config_t, 3); config_t[0] = 0x00; tempsensor.write(TEMP_ADDR, config_t, 1); while(1) { tempsensor.read(TEMP_ADDR, temp_read, 2); temp_reading = 0.0625 * (((temp_read[0] << 8) + temp_read[1]) >> 4)*1.8 + 32.0; display5sec(temp_reading); } }

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 display5sec(float temp) { int s; unsigned int tempDisplay = static_cast(temp*10); for (s = 0; s < 250; s++) { digselect = 0x1; digit = segDriverDigit(tempDisplay/1000); wait_ms(5); digselect = 0x2; digit = segDriverDigit(tempDisplay/100); wait_ms(5); digselect = 0x4; digit = segDriverDigit(tempDisplay/10)& DIGIT_PT; wait_ms(5); digselect = 0x8; digit = segDriverDigit(tempDisplay%10); wait_ms(5); } return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

Define absenteeism.

Answered: 1 week ago