Paso 3: Codificación y pruebas
//Enjoy :) #include int thermistorPin = A0; //analog pin 0 int Relay = 4; float vPow = 4.7; float r1 = 50000.0; float r2 = 4400.0; LiquidCrystal lcd(7, 8, 9, 10, 11, 12); void setup() { Serial.begin(9600); lcd.begin(16,2); Serial.print("\x1B"); Serial.print("[2J"); Serial.print("\x1B"); Serial.println("[H"); Serial.println("--------------------"); Serial.println("DC VOLTMETER"); Serial.print("Maximum Voltage: "); Serial.print((int)(vPow / (r2 / (r1 + r2)))); Serial.println("V"); Serial.println("--------------------"); Serial.println(""); } void loop() { float v = (analogRead(1) * vPow) / 1024.0; float v2 = v / (r2 / (r1 + r2)); int thermistorReading = analogRead(thermistorPin); Serial.print("\x1B"); Serial.print(""); Serial.println(thermistorReading); Serial.println(v2); lcd.setCursor(0, 0); lcd.print(v2); lcd.print(" V"); lcd.setCursor(0, 1); lcd.print(thermistorReading); lcd.print(" Temp"); if (v2 <= 5.39 ) { digitalWrite (4,HIGH); } if (v2 >= 5.40 ) { digitalWrite (4,LOW); } delay(8000); } //narzan qarma
.