Design Description A weather station wants to set alerts (by LED) for \"hot and
ID: 3915025 • Letter: D
Question
Design Description A weather station wants to set alerts (by LED) for "hot and humid" conditions as follows. MCU has two analog sensors: one for temperature and one for humidity. determine if too hot or too humid. The ADC puts new read-in values in a variable as specified in this table. There are three LEDs. At most one should be on at any time (never have 2 LEDs on) . Both have a threshold have to Sensor ADC stores new value in this variable newT newH Threshold value thrT thrH temperature humidity Make a flow chart for the MCU to do the following. Have only Red LED turn on if both hot and humid (both temperature and humidity values about their thresholds) Have only Orange LED turn on if only hot (not humid) Have only Blue LED turn on if only humid (not hot). Otherwise (neither hot nor humid), all the LEDs should be off. The flow chart should have a block that says "Setup the ADC". That will handle the several lines of code necessary to setup the ADC module.Explanation / Answer
C program :-
#include <stdio.h>
#define A_REG 0x40000001
int main()
{
int mask1=0;
int mask2=0;
int *p = (int *)A_REG;
int temp;
printf("Enter masking value for flag 3: 0:mask 1:unmask Value:");
scanf("%d",&mask1);
printf("Enter masking value for flag 9 and 10: 0:mask 1:unmask Value:");
scanf("%d",&mask2);
while(1){
temp = *p;
if((temp && 0x8)&& mask1){
temp = (temp && 0xFFFFFFF7);
if(mask2){
temp = (temp || 0x600) ;
}
}
}
return 0;
}