PP2
PP2
Below is a (partial) RIM C program that appropriately sets the display for the given dial position:
#include "RIMS.h"
void main()
{
while (1) {
switch( A )
{
case 0 : B = 0x77; break; // 0111 0111 (0)
case 1 : B = 0x24; break; // 0010 0100 (1)
case 2 : B = 0x5D; break; // 0101 1101 (2)
//...
case 9 : B = 0x6F; break; // 0110 1111 (9)
default: B = 0x5B; break; // 0101 1011 (E for Error)
}
}
}
i) What B_ outputs should be set to 1 for case 3? List in ascending order separated by
spaces, e.g., B0 B2 ... [2 marks]
ii) To what should B be set for case 3? B = ____; Use uppercase letters for the hex literal.
[2 marks]
b) Design a state machine for a simple traffic light control system with three states: Green, Yellow, and
Red. The system should transition between states in the traditional sequence, with timers controlling the
duration of each state.
i. State Diagram: Draw a state diagram for the traffic light control system. Label each state and
transition clearly. [3 marks]
ii. State Transition Table: Create a state transition table that includes current states, input (timer
expiration), and next states. [4 marks]
iii. Implementation: Write pseudocode for the state machine. Include initialization, state transitions,
and timer management. [5 marks]
iv. Enhancements: Suggest one enhancement to improve traffic flow or safety and describe how it
can be integrated into the current state machine model. [4 marks]
i) 0 s [3 marks]
ii) 1 s [3 marks]
iii) 2 s [3 marks]
iv) 3 s [3 marks]
v) 4 s [ 3 marks]
QUESTION FOUR (15 marks)
Design and implement an automated plant watering system using Arduino. This system should monitor soil
moisture levels and automatically water the plant when the soil is dry.
a) System Design: Sketch the circuit diagram for connecting the soil moisture sensor and water pump
to the Arduino. Include a brief description of how each component interacts with the Arduino.
[3 marks]
b) Programming Logic: Write an Arduino program that reads the moisture level from the sensor. The
program should activate the water pump when the soil moisture level falls below a predefined
threshold. Include comments to explain the logic of your code. [6 marks]
c) Energy Efficiency: Discuss strategies to make your automated watering system energy-efficient.
Propose at least one method and explain its implementation in the context of your project.
[3 marks]
d) Scalability: Describe how your system could be scaled to manage multiple plants, considering
factors such as circuit complexity and code modifications. [3 marks]
Additional Guidelines:
• Provide a list of materials needed for your project.
• Ensure your code is well-commented to demonstrate your thought process.
• Consider practical aspects such as the water source and how to avoid overwatering.