/************************************************************************/ /* */ /* Program Name: NRLink-PF-macro-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; task main() { byte i, j; nI2CBytesReady[NRLinkPort] = 0; SensorType[NRLinkPort] = sensorI2CCustom9V; NRLinkSendCommand(NRLinkPort, NRLinkID, NRLinkFlush); NRLinkSendCommand(NRLinkPort, NRLinkID, NRLinkDefault); NRLinkSendCommand(NRLinkPort, NRLinkID, 'P'); // required when you are running PF motors. NRLinkWriteMacroByte(NRLinkPort, NRLinkID, 0x80, 0x02); NRLinkWriteMacroByte(NRLinkPort, NRLinkID, 0x81, 0x01); NRLinkWriteMacroByte(NRLinkPort, NRLinkID, 0x82, 0x60); NRLinkPrintMacro(NRLinkPort, NRLinkID, 0x80, 2); while(true) { NRLinkRunMacro(NRLinkPort, NRLinkID, 0x80); // run the macro wait1Msec(1000); } } /* RCX Opcode reference: http://graphics.stanford.edu/~kekoa/rcx/opcodes.html */