// Ohmmetro V1.2 By Valter & Samuele (Nov. 2007) #include "NXCDefs.h" unsigned long R; // value calculated resistance /* ---------------------------- START PROGRAM -------------------------*/ task main() { SetSensorType (IN_1, IN_TYPE_SWITCH); // NXT input 1 SetSensorMode (IN_1, IN_MODE_RAW); while(true) { // Calculation: R = (RAW * 10000) / (1023 - RAW) R = (SENSOR_1 * 10000)/(1023 - SENSOR_1); if (R != 0) { ClearScreen(); // clear display TextOut(12, 8, " ohm"); NumOut(50, 8, R); // display value in ohms if (R >= 10000) { TextOut(12, 24, "Kohm"); NumOut(50, 24, (R / 1000)); // display value in Kohms } } else { ClearScreen(); TextOut(20, 16, "(Infinite)"); // display infinite if R = 0 TextOut(6, 8, "Insert Resistor"); } TextOut(13, 48, "Ohmmetro V1.2"); TextOut(3, 44, "By Valter & Samu"); Wait (400); // pause 0,4 sec (reading data) } } /* ---------------------------- END PROGRAM -------------------------*/