NXC Elevator Program
ECE-206 HW-05A Page 1 of 1
HW-05A: NXC Elevator Program
Using the structured flowchart, write an NXC program for the elevator control described in
Homework 3. Because the elevator needs nine sensors and the NXT has only four sensor inputs,
the NXC program is not intended to control the elevator due to the insufficient sensor inputs. It
is, however, intended to be a practice in translating a flowchart into NXC codes. We shall
improvise by defining the sensors based on the following Table 1 so that your program can be
compiled by NXC compiler in Bricx Command Center without syntax errors. See Homework 3
for the description of the elevator control and legend.
Table 1: Sensor Definitions
Sensor Names Sensors Defined as
SENSOR1, SENSOR2, SENSOR3, SENSOR4 SENSOR_1
SENSOR5, SENSOR6, SENSOR7, SENSOR8, SENSOR9 SENSOR_2
Sensor Definition Example: #define SENSOR1 SENSOR_1
#define SENSOR2 SENSOR_2
Sensors Assignments:
Sensors Type Mode Value Usage
-------------------------------------------------------------------------------------------------------------------- SENSOR1 TOUCH BOOL 1= pressed; 0 = not pressed button pressed
SENSOR2 TOUCH BOOL 1= pressed; 0 = not pressed button pressed
SENSOR3 TOUCH BOOL 1= pressed; 0 = not pressed Floor 1 calls ↑
SENSOR4 TOUCH BOOL 1= pressed; 0 = not pressed Floor 2 calls ↓ SENSOR5 LIGHT Percent <40 on 1st floor On 1st floor
SENSOR6 LIGHT Percent <40 on 2nd floor On 2nd floor
SENSOR7 LIGHT Percent <40 door completely closed Door closed
SENSOR8 LIGHT Percent <40 door completely open Door open
SENSOR9 LIGHT Percent <40 someone obstructing door safety
Outputs assignments:
Outputs Value Usage
-------------------------------------------------------------------------------------------------------
OUT_A forward = UP; reversed = DOWN Elevator going UP or DOWN
OUT_B forward = open; reversed = close Elevator door open or close
Program Requirement:
1. Must include all sensor configurations.
2. Must have a one-to-one mapping with the structured flowchart.
3. Must include a comment header for the description of the program.
4. Must include plenty of comment statements to explain the flow of instructions
5. Must include proper indentation.
Work to do and document to submit:
1. A copy of the structured flowchart.
2. A fully documented NXC program that passed the compilation with no syntax errors.
As it has been stipulated, the program will not work due to sensor input shortage.