Problem 1:
a. Write a program, (complete with remarks), that will blink LED on Pin0 on and off (every ½ second), as long
as the switch on Pin2 is pressed. When the switch is not pressed, LED Pin1 is on to show the programme is ready, but goes off when LED Pin0 is flashing.
Problem 2:
Write a program that will blink both LED’s (every 1.2 seconds) when either input 4 or 5 are high. If no
switches are pressed the LED’s are off.
Problem 3:
Write a program that will alternately blink two LED’s on and off (continuously) every ½ second, but
only after switch P2 has been pressed first (and released) , and then switch P3 is pressed.
What would change if you wish to reverse the “switch press” order.
Problem 4:
Write a program that will blink the LED’s (every .2 seconds) whenever switch P2 is pressed. Then if
while switch P2 is still depressed, switch P3 is pressed – will put the LED’s off.
Problem 5:
A set of traffic lights, (2 lights), is used to control a road works. The lights change in the sequence RED – RED & AMBER – GREEN – AMBER – RED.
The lights sequence changes every 50 seconds, each light is on for 10 seconds during the change. When one end shows RED the other end shows GREEN. The lights must control the flow of traffic safely.
Problem 6:
A remote robot needs to be able to find the way out of a room. It has 2 touch sensors, left and right that can sense when a wall is reached and two motors to provide drive and direction. The motors can be run forwards or backwards. Turning is done by stopping either motor or by reversing one motor whilst the other goes forward. The turn will be towards the stopped or reversed motor. When a wall is reached backup slightly and turn
away from the sensor that has been activated.
Problem 7:
A delivery system uses a rotary valve. This valve is driven by a motor and will allow 40 gms of material through every full rotation. The motor is started by pressing a switch. We need to design a programme that will deliver 1000 gms when the start switch is pressed. The motor shaft has a cam and switch on it that gives an input once every turn of the motor.
Problem 8:
A robot has two light sensors connected to Pin0 and Pin1. These light sensors give a high signal when they are over a white line. Write a programme to control the robot using two motors, left and right to steer the robot and keep it over the line. Your programme might lose the line, if this happens make the robot circle until the line is found again and then follow it. If it has not seen the line after a reasonable time limit, say 30 seconds, it should stop.
ALL PROGRAMME LINES SHOULD BE COMMENTED WITH WHAT THEY DO. See above.
- A sensor connected to input 3 is switched on when a person is detected. A low level alarm connected to pin 4 is sounded for 12 seconds, this switched on and off every 2 seconds in this time. If the reset on pin 1 is switched on in this time the system will reset. If not the main alarm on pin 0 is sounded until the reset – Pin 1 - is turned on.
- A cat is fed every 4 hours. The cat is fed when output 4 is turned on. For 10 seconds.
- A car park is controlled by a barrier. When a car arrives input 3 will be turned on. The barrier is lifted by switching on output 0. When the barrier reached the top input 1 is turned on the barrier stops. Waits for 30 seconds and then lowers by turning on output 4. When the barrier reaches the bottom input 2 is turned on. The barrier stops. The car park holds 100 cars and the barrier will not lift if the car park is full.
- A fan is turned on if the temperature of a thermistor connected to input 1 is reading more than 100. When the temperature falls below 50 the fan is turned off.
- A bell connected to output 0 is rung every hour. It rings however many times the hour is so at 11 o clock it will ring 11 times.
- An LED is connected to output 2. A sensor is connected to input 3. Input 3 will be on if the sensor detects light. If the sensor detects light the LED should be switched on and stay on even if the light is removed. The LED can be reset by setting input 1 on.