اووو من عدد را مثال زدم و در پروژه خودم عددی نیست ... اینم تصاویر چیزای که میخوام بصورت منو عوض بشه ...
![]()
![]()
اما وقتی روی یکی از پارامترهای نشان داده میرم، بعد از اینکه میخواهد به حالت اول بازگردد، چند تا از حروف از حالت قبل در تصویر می ماند ...!!!
این کدهای منه، میخوام اونای که نمایش بدم بصورت منو باشن، البته الان این را آپلود نکردم، این پارامترهام هستند که بلد نیستم منو بسازم که عوض بشن
کد HTML:#include "EmonLib.h" // Include Emon Library EnergyMonitor emon1; // Create an instance // include LCD the library: #include <LiquidCrystal.h> // select the pins used on the LCD panel LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // define some values used by the panel and buttons int lcd_key = 0; int adc_key_in = 0; #define btnRIGHT 0 #define btnUP 1 #define btnDOWN 2 #define btnLEFT 3 #define btnSELECT 4 #define btnNONE 5 // read the buttons int read_LCD_buttons() { adc_key_in = analogRead(0); // read the value from the sensor // my buttons when read are centered at these valies: 0, 144, 329, 504, 741 // we add approx 50 to those values and check to see if we are close if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result if (adc_key_in < 50) return btnRIGHT; if (adc_key_in < 195) return btnUP; if (adc_key_in < 380) return btnDOWN; if (adc_key_in < 555) return btnLEFT; if (adc_key_in < 790) return btnSELECT; return btnNONE; // when all others fail, return this... } void setup() { Serial.begin(9600); // set up the LCD’s number of columns and rows: lcd.begin(20, 4); emon1.voltage(2, 234.26, 1.7); // Voltage: input pin, calibration, phase_shift emon1.current(1, 111.1); // Current: input pin, calibration. } void loop() { emon1.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out emon1.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor) unsigned int long timemillis=millis(); //keeping the track of the time since the device is switched ON unsigned int long time=timemillis/1000; float realPower = emon1.realPower; //extract Real Power into variable float apparentPower = emon1.apparentPower; //extract Apparent Power into variable float powerFactor=emon1.powerFactor;//extract Apparent Power into variable rFactor = emon1.powerFactor; //extract Power Factor into Variable float supplyVoltage = emon1.Vrms; //extract Irms into Variable float Irms = emon1.Irms; //displaying the values lcd.setCursor(1,0); lcd.print("Energy Monitor"); lcd.setCursor(0,1); lcd.print("V="); lcd.print(supplyVoltage); lcd.setCursor(9,1); lcd.print("I="); lcd.print(Irms); lcd.setCursor(-4,2); lcd.print("PowerFactor="); lcd.print(powerFactor); lcd.setCursor(-4,3); lcd.print("Units(kWh)="); lcd.print(abs(realPower*time)/abs(1000*3600)); lcd.setCursor(-4,4); lcd.print("(kW)="); lcd.print(realPower/1000); lcd.setCursor(-4,5); lcd.print("(KVA)="); lcd.print(apparentPower/1000); lcd.setCursor(-4,6); lcd.print("(KVAR)="); lcd.print((sqrt((apparentPower*apparentPower)-(realPower*realPower)))/1000); }


12 لایک
LinkBack URL
About LinkBacks



پاسخ با نقل قول