#define A0IN 0 #define A1IN 1 int analogamount = 0; // used to convert voltage left bridge int analogamount1 = 0; // used to convert voltage right bridge float voltage = 0; // left bridge voltage float voltage1 = 0; // right bridge voltate float voltage2 = 0; // used for voltage correction float answer = 0; int cv = 0; // counter variable used screen drawing void setup() { analogReference(EXTERNAL); // use AREF for reference voltage Serial.begin(9600); set_screen(); } void loop() { analogamount = analogRead(A0IN); analogamount1 =analogRead(A1IN); voltage=analogamount * (4500 / 1023.00); voltage1=analogamount1 * (4500 / 1023.00); voltage2 = 0; set_xy(23,1); save_cursor_pos(); if(voltage == voltage1) { set_xy(10,25); repeat_char(10,0x20); set_xy(10,47); repeat_char(10,0x20); set_xy(14,49); repeat_char(10,0x20); } else { set_xy(10,25); voltage = round(voltage); voltage = voltage * .001; Serial.print(voltage); if( voltage < 1) { Serial.print("mV"); } else { Serial.print("V ");} set_xy(10,47); voltage1 = voltage1 * .001; Serial.print(voltage1); if( voltage1 < 1) { Serial.print("mV"); } else { Serial.print("V ");} set_xy(14,49); voltage2 = voltage * 2; answer = 10000 * voltage1 / (voltage2 - voltage1); answer = round(answer); Serial.print( (int) answer); Serial.print(" Ohms "); } restore_cursor_pos(); delay(3000); } void save_cursor_pos(){ Serial.print("\x1B" "[s"); // save cursor position } void restore_cursor_pos(){ Serial.print("\x1B" "[u"); // restore cursor position } void repeat_char(int r,char c){ int rx; for(rx = 0; rx != r; rx++){ Serial.print(c); } } void set_xy(int x, int y){ Serial.print("\x1B["); Serial.print(x); Serial.print(";"); Serial.print(y); Serial.print("H"); } void set_screen(){ Serial.print("\x1B" "[2J"); set_xy(1,2); Serial.print("Ohmmeter"); set_xy(3,2); Serial.print("\xDA"); repeat_char(20,0xc4); Serial.print("\xC2"); repeat_char(20,0xc4); Serial.print("\xBF"); set_xy(4,2); for(cv = 0; cv != 2; cv++){ Serial.print("\xB3"); repeat_char(20,0x20); Serial.print("\xB3"); repeat_char(20,0x20); Serial.println("\xB3"); Serial.print(" "); } set_xy(6,2); for(cv = 0; cv != 3; cv++){ Serial.print("\xB3"); repeat_char(20,0x20); Serial.print("\xB2"); repeat_char(20,0x20); Serial.println("\xB2"); Serial.print(" "); } set_xy(7,25); Serial.print("R1 (10K)"); set_xy(9,1); Serial.print("\xC4\xC1\xC4"); repeat_char(19,0x20); Serial.print("\xB3"); repeat_char(20,0x20); Serial.print("\xB3"); set_xy(10,1); Serial.print("\x1B[10;1H" " \xC4 "); repeat_char(19,0x20); Serial.print("\xB3"); repeat_char(20,0x20); Serial.print("\xB3"); set_xy(11,1); Serial.print("\xC4\xC4\xC4"); repeat_char(19,0x20); Serial.print("\xB3"); repeat_char(20,0x20); Serial.print("\xB3"); set_xy(12,2); Serial.print("\xC2 "); repeat_char(19,0x20); Serial.print("\xB3"); repeat_char(20,0x20); Serial.print("\xB3"); set_xy(13,2); for(cv = 0; cv != 3; cv++){ Serial.print("\xB3"); repeat_char(20,0x20); Serial.print("\xB2"); repeat_char(20,0x20); Serial.println("\xB2"); Serial.print(" "); } set_xy(16,2); for(cv = 0; cv != 3; cv++){ Serial.print("\xB3"); repeat_char(20,0x20); Serial.print("\xB3"); repeat_char(20,0x20); Serial.println("\xB3"); Serial.print(" "); } set_xy(18,2); Serial.print("\xC0"); repeat_char(20,0xc4); Serial.print("\xC1"); repeat_char(20,0xc4); Serial.print("\xD9"); set_xy(7,46); Serial.print("R2 (10K)"); set_xy(14,25); Serial.print("R3 (10K)"); set_xy(14,46); Serial.print("Rx"); }