/************************************************************************/ /* */ /* Program Name: NRLink-Nx-RCX-sample.c */ /* =========================== */ /* */ /* Copyright (c) 2008 by mindsensors.com */ /* Email: info () mindsensors () com */ /* */ /* This program is free software. You can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; version 3 of the License. */ /* Read the license at: http://www.gnu.org/licenses/gpl.txt */ /* */ /************************************************************************/ #include "NRLink-lib.c" const tSensors NRLinkPort = S1; // Connect NRLink sensor to this port!! const ubyte NRLinkID = 0x02; byte replyMsg[7]; /////////////////////////////////////////////////////////////////////////////// // // Run Some commands and macro to control RCX using NRLink. // ///////////////////////////////////////////////////////////////////////////// task main() { byte Data[10]; nI2CBytesReady[NRLinkPort] = 0; SensorType[NRLinkPort] = sensorI2CCustomFast9V; nxtDisplayTextLine(0,"mindsensors.com"); nxtDisplayTextLine(1,"NRLink"); NRLinkSendCommand(NRLinkPort, NRLinkID, NRLinkFlush); NRLinkSendCommand(NRLinkPort, NRLinkID, NRLinkDefault); while(1) { NRLinkRunMacro(NRLinkPort, NRLinkID, RCX_Motor_A_FWD); wait10Msec(20); NRLinkRunMacro(NRLinkPort, NRLinkID, RCX_Motor_C_REV); wait10Msec(20); NRLinkRunMacro(NRLinkPort, NRLinkID, RCX_Motor_C_FWD); wait10Msec(20); NRLinkRunMacro(NRLinkPort, NRLinkID, RCX_Motor_A_REV); wait10Msec(20); NRLinkRunMacro(NRLinkPort, NRLinkID, RCX_Beep); wait10Msec(20); } StopAllTasks(); }