computer science lab report
ECE-206 (Friday), Spring 2016 Exercise #04 Page 1 of 1
Exercise #04: NXC Programming - Automatic Sliding Door Control
Prelab: First draft of the NXC program
Discussion:
Repeat Laboratory Exercise #3 but translate the modified flowchart into NXC codes.
Using NXC codes, the programmer must explicitly specify the sensor type and sensor mode. For
example, if sensor 1 is a touch sensor which gives a “0” when it is not touched and gives a “1”
when it is touched, then the NXC codes must specify the sensor type TOUCH and sensor mode
BOOL for sensor 1 as follows:
SetSensorType(S1, SENSOR_TYPE_TOUCH); //case sensitive
SetSensorMode(S1, SENSOR_MODE_BOOL); //must type as is
Use NXC instructions to set sensor 2 and sensor 3 mode and type as follows:
SetSensorType(S2, SENSOR_TYPE_LIGHT); //sensor 2 is a light sensor SetSensorMode(S2, SENSOR_MODE_PERCENT); //in percent mode
SetSensorType(S3, SENSOR_TYPE_LIGHT); //sensor 3 is a light sensor
SetSensorMode(S3, SENSOR_MODE_PERCENT); //in percent mode
For your convenience, the sensors and the motor wiring to NXT are repeated as follows:
SENSOR_1 : Pressure Sensor ( use a Touch sensor instead) placed under the door mat.
Touch Sensor reading = 0 means no one on the mat
= 1 means someone on the mat
SENSOR_2 : Light Sensor for detecting door is completely open.
Light Sensor reading < 40 (black) means door completely open
>= 40 (white) means door not completely open
SENSOR_3 : Light Sensor for detecting door is completely close.
Light Sensor reading < 40 (black) means door completely close
>= 40 (white) means door not completely close
OUT_A : Motor.
Forward = close door;
Reverse = open door
Material to submit:
Post Lab: Well documented NXC program
Have the instructor verify that your NXC program
works as specified.
Post Laboratory Questions
Investigate a sliding door on a commercial building
in your area; pay attention on the drive mechanism,
the safety mechanism, the entry-request detection
mechanism, etc.
Compare and contrast the commercial sliding door with the one in the lab. Include discussion on
the hardware and software.