1 / 11

NQC: Main Program

NQC: Main Program. task main() { OnFwd(OUT_A); OnFwd(OUT_B); Wait(400); OnRev(OUT_A+OUT_B); Wait(400); Off(OUT_A+OUT_B); }. Statement Block. NQC: Main Program. void turn_around() { OnRev(OUT_C); Wait(340); OnFwd(OUT_A+OUT_C); } task main() { ……………………… ..

bendek
Télécharger la présentation

NQC: Main Program

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. NQC: Main Program task main() { OnFwd(OUT_A); OnFwd(OUT_B); Wait(400); OnRev(OUT_A+OUT_B); Wait(400); Off(OUT_A+OUT_B); } Statement Block

  2. NQC: Main Program void turn_around() { OnRev(OUT_C); Wait(340); OnFwd(OUT_A+OUT_C); } task main() { ……………………….. turn_around(); Wait(200); turn_around(); ……………………….. Off(OUT_A+OUT_C); } Function Block Statement Block

  3. NQC: Main Program int move_time, turn_time; task main() { while(true) { move_time = Random(60); ………………………………. OnRev(OUT_A); Wait(turn_time); } } Defining global variables Statement Block

  4. NQC: Main Program task main() { SetSensor(SENSOR_1,SENSOR_TOUCH); start check_sensors; start move_square; } task move_square() { …………………………………. } task check_sensors() { …………………………………… } Multi-tasking Task 1 Task 2

  5. NQC: Setting up Sensors Variable corresponding to Channel 1 • SetSensor(SENSOR_1, SENSOR_TOUCH); • SetSensor(SENSOR_2, SENSOR_LIGHT); • SetSensor(SENSOR_3,SENSOR_ROTATION); • SetSensor(SENSOR_1, SENSOR_CELSIUS); • SetSensor(SENSOR_2, SENSOR_FAHRENHEIT); • SetSensor(SENSOR_3, SENSOR_PULSE); Touch Sensor

  6. NQC: Outputs • SetOutput(outputs, mode) • Set the outputs to the specified mode. Outputs is one or more of OUT_A, OUT_B, and OUT_C. Mode must be OUT_ON, OUT_OFF, or OUT_FLOAT. SetOutput(OUT_A + OUT_B, OUT_ON); // turn A and B on

  7. NQC: Outputs • Output Mode • OUT_OFF //output is off (motor is prevented from turning) • OUT_ON //output is on (motor will be powered) • OUT_FLOAT //motor can "coast"

  8. NQC: Outputs • SetDirection(outputs, direction) • Set the outputs to the specified direction. Outputs is one or more of OUT_A, OUT_B, and OUT_C. Direction must be OUT_FWD, OUT_REV, or OUT_TOGGLE. SetDirection(OUT_A, OUT_REV);

  9. NQC: Outputs • Direction • OUT_FWD Set to forward direction • OUT_REV Set to reverse direction • OUT_TOGGLE //Switch direction to the opposite of what it is presently

  10. NQC: Outputs SetPower(outputs, power) • Sets the power level of the specified outputs. Power may be an expression, but should result in a value between 0 and 7. The constants • OUT_LOW, • OUT_HALF, and • OUT_FULL may also be used. • SetPower(OUT_A, OUT_FULL); // A full power • SetPower(OUT_B, x);

  11. NQC: Outputs On(outputs)  On(OUT_A + OUT_C); Off(outputs)  Off(OUT_A); Fwd(outputs)  Fwd(OUT_A); Rev(outputs)  Rev(OUT_A); Toggle(outputs)  Toggle(OUT_A); OnFwd(outputs)  OnFwd(OUT_A); OnRev(outputs)  OnRev(OUT_A); OnFor(outputs, time)  OnFor(OUT_A, x);

More Related