Hi
Ich möchte gerne, dass auf meinem OLED-Display bei Erfüllen der IF-Bedingung (HIGH am digitalen Eingang 7) der String "WATER ALARM" gross erscheint und die anderen Strings dabei ausgebledet werden.
Weiss wer, wie das mit der u8glib geht?
Danke!
#include "U8glib.h" // U8glib library for the OLED
U8GLIB_SSD1306_ADAFRUIT_128X64 u8g(13, 11, 10, 9, 8);
int analogInput = 0;
float vout = 0.0;
float vin = 0.0;
float R1 = 102000.0; // resistance of R1 (100K)
float R2 = 10000.0; // resistance of R2 (10K)
int value = 0;
int analogInput2 = 1;
int value2 = 0;
int waterAlarm = 7;
int water = 0;
float vout2 = 0.0;
float vin2 = 0.0;
void draw(void)
{
u8g.drawStr(0, 12, "VOLTAGE ROV:");
u8g.drawStr(0, 36, "DEPTH:");
u8g.drawStr(0, 60, "HEADING:");
u8g.setPrintPos(90, 12);
//u8g.drawRFrame(15, 20, 100, 30, 10); // draws frame with rounded edges
u8g.println(vin); //Prints the voltage
u8g.println("V");
u8g.setPrintPos(90, 36);
u8g.println(vin2);
u8g.println("m");
}
void setup(){
pinMode(analogInput, INPUT);
pinMode(analogInput2, INPUT);
pinMode(waterAlarm, INPUT);
}
void loop(){
u8g.setFont(u8g_font_profont12);
// read the value at analog input
value = analogRead(analogInput);
vout = (value * 5.0) / 1024.0; // see text
vin = vout / (R2/(R1+R2));
if (vin<0.09) {
vin=0.0;//statement to quash undesired reading !
}
value2 = analogRead(analogInput2);
vout2 = (value2 * 5.0) / 1024.0;
vin2 = (vout2 - 0.5) * 2.5;
water = digitalRead(waterAlarm);
if (water == HIGH){ // when water touches the water sensor
u8g.setFont(u8g_font_profont22);
u8g.drawStr(0, 36, "WATER ALARM");
}
u8g.firstPage();
do
{
draw();
}
while( u8g.nextPage() );
delay(500);
}