// TeleCam NQC code - Accepts simple numeric messages and twitches // the camera in the appropriate direction. // http://fastolfe.net/features/telecam/ // // Copyright (c) 1999 David Nesting // // 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; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software Foundation, // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Commands transmitted from the IR tower -- We're using 1/2 for tilt and // 3/4 for pan. #define STAT 0 #define UP 1 #define DOWN 2 #define LEFT 3 #define RIGHT 4 // Motor timings -- The motor stays on for this many hundredths of a // second and then stops. Your gearing may be different and require // these values to be adjusted. #define PAN_TIMING 20 #define TILT_TIMING 2 // The message received from the tower int msg; task main() { // Let the user know we're up and running. repeat (2) { PlaySound(1); Wait(100); } SetPower(OUT_A + OUT_C, OUT_FULL); while (true) { ClearMessage(); until (Message() > 0); msg = Message(); if (msg == STAT) { SendMessage(1); } else if (msg == LEFT) { Rev(OUT_A); OnFor(OUT_A, 20); Off(OUT_A); } else if (msg == RIGHT) { Fwd(OUT_A); OnFor(OUT_A, 20); Off(OUT_A); } else if (msg == UP) { Fwd(OUT_C); OnFor(OUT_C, 2); Off(OUT_C); } else if (msg == DOWN) { Rev(OUT_C); OnFor(OUT_C, 2); Off(OUT_C); // The rest of these messages are just for sound effects. } else if (msg == 5) { PlaySound(2); } else if (msg == 6) { PlaySound(3); } else if (msg == 7) { PlaySound(4); } else if (msg == 8) { PlaySound(5); } else if (msg == 9) { PlaySound(6); } else if (msg == 10) { PlaySound(7); } } }