Académique Documents
Professionnel Documents
Culture Documents
Outputs
fan motor
heater
PORTC_Bit0
PORTC_Bit1
Problem 6
Fridge door
You are to turn the fridge light on when the door is opened and off when the door is shut. If
the door is left open for more than 30 seconds then turn on a warning beeper pulsing every 2
seconds. Note you are to use the real time interrupts for your delay.
Inputs
Door sensor
Outputs
PINA_Bit0
Fridge light
Beeper
PORTB_Bit6
PORTD_bit1
Question 7
A two way light switch is often seen in a hallway, where a light switch is placed at either end
of the hall. Either switch can be used to turn the light on or off. The interesting thing being
that if both light switches start in the off position, then when a light switch is turned on at one
switch, (light now on), then when the second switch is turned on the light will now turn off.
This can be shown electrically as below.
Light Bulb
Power
Inputs
Switch 1
Outputs
PINA_Bit0
Light bulb
PORTB_Bit6
Hint look for a change of state on the switches and if they change then to toggle the light and
then store the new state of the switches. Storing the state of the switches is simple if bit
masking is used.
Question 8
Robot Control
You are designing a robot to move toward a light source. Three digital photo sensors S L, SC,
and SR with sharply defined non overlapping fields of view are mounted at the front of the
robot pointing 45o to the left, straight ahead, and 45o to the right, respectively. Two wheels WL
and WR are powered depending on the output of the sensors. If the left sensor S L detects light,
the robot is pointing too far to the right, and the right wheel W R must be switched on to turn
the robot to the left. The opposite is necessary if the right sensor S R receives light. If the
forward-pointing sensor SC detects light, then both wheels WL and WR should be turned on. If
no sensor detects light then turn on the left wheel WL. Treat the sensors as having binary
outputs, i.e., either "on" or "off", and the powered wheels as being "on" or "off".
Inputs
Right Sensor SR
Center Sensor SC
Left Sensor SL
Outputs
PINA_Bit0
PINA_Bit1
PINA_Bit2
Right Wheel WR
Left Wheel WL
PORTC_Bit0
PORTC_Bit1