The campus bus uses an embedded system that tracks the number of passengers getting in and those getting out of the bus. Two circuits with laser photodiodes, connected to RB0 (getting in) and RB1 (getting out), are used to track these numbers. At any time, the total number of passengers is equal to the total passengers entering in minus the total of those getting out of the bus. Whenever the total number of passengers in the bus reaches its maximum capacity (assumed equal to 30), the system turns on a red LED (connected to RD1). If the number is under 30, the system turns a green LED (connected to RD0).
a) Write an algorithm for the program
b) Translate the algorithm to a C program