Bygga en flytande givare, kapacitiv (7 / 8 steg)
Steg 7: programmering
LiquidCrystal.h http://arduino.cc/en/Tutorial/LiquidCrystal
CapSense.h http://www.arduino.cc/playground/Main/CapSenseKopiera och förbi detta till Arduino 0017 eller nyare.
Givare, kapacitiv flytande
Vadim 7 December 2009
#include
#include
Detta är att ställa in storleken på LCD-skärmen
CONST int numRows = f = 4;
CONST int numCols = 20;
Detta ställer in stiften för lcd (RS, aktiverar, data 0-7)
LiquidCrystal lcd (53 52, 51, 50, 49, 48,47,46,45,44);
#define tempin 0x48
#define Tempout 0x49
CapSense cs_22_23 = CapSense(22,23);
uint8_t block [8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
uint8_t tl [8] = {0x0F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0F, 0x0F};
uint8_t tr [8] = {0x16, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1D, 0x15};
uint8_t bl [8] = {0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x1F};
uint8_t br [8] = {0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x12, 0x18};
void setup() {
LCD.BEGIN (numRows, numCols);
lcd.createChar (4, tl).
lcd.createChar (5, tr).
lcd.createChar (6, bl);
lcd.createChar (7, br);
lcd.setCursor(18,0);
LCD.Print (4, BYTE).
lcd.setCursor(19,0);
LCD.Print (5, BYTE).
lcd.setCursor(18,1);
LCD.Print (6, BYTE).
lcd.setCursor(19,1);
LCD.Print (7, BYTE).
lcd.setCursor(0,2);
LCD.Print ("bränsle").
lcd.setCursor(0,3);
LCD.Print("E");
}
void loop() {
långa bränsle.
lcd.createChar (2, block);
långa start = millis();
bränsle = cs_22_23.capSenseRaw(200);
Temratue gör lite av en difrence så låt den köra i 5 min innan trimning.
Justera detta nummer så att produktionen är så nära noll som möjligt.
bränsle = bränsle - 7200;
Fyll sedan upp conataner
O-kommentera och justera detta så att utdata, när behållaren är full,
är så nära 100 som möjligt.
bränsle = bränsle / 93;
lcd.setCursor(0,0);
LCD.Print("");
lcd.setCursor(0,0);
LCD.Print(Fuel);
om (bränsle > = 6) {
lcd.setCursor(1,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(1,3);
LCD.Print("");
}
om (bränsle > = 12) {
lcd.setCursor(2,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(2,3);
LCD.Print("");
}
om (bränsle > = 17) {
lcd.setCursor(3,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(3,3);
LCD.Print("");
}
om (bränsle > = 23) {
lcd.setCursor(4,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(4,3);
LCD.Print("");
}
om (bränsle > = 28) {
lcd.setCursor(5,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(5,3);
LCD.Print("");
}
om (bränsle > = 34) {
lcd.setCursor(6,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(6,3);
LCD.Print("");
}
om (bränsle > = 39) {
lcd.setCursor(7,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(7,3);
LCD.Print("");
}
om (bränsle > = 44) {
lcd.setCursor(8,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(8,3);
LCD.Print("");
}
om (bränsle > = 50) {
lcd.setCursor(9,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(9,3);
LCD.Print("");
}
om (bränsle > = 55) {
lcd.setCursor(10,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(10,3);
LCD.Print("");
}
om (bränsle > = 60) {
lcd.setCursor(11,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(11,3);
LCD.Print("");
}
om (bränsle > = 64) {
lcd.setCursor(12,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(12,3);
LCD.Print("");
}
om (bränsle > = 69) {
lcd.setCursor(13,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(13,3);
LCD.Print("");
}
om (bränsle > = 74) {
lcd.setCursor(14,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(14,3);
LCD.Print("");
}
om (bränsle > = 78) {
lcd.setCursor(15,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(15,3);
LCD.Print("");
}
om (bränsle > = 83) {
lcd.setCursor(16,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(16,3);
LCD.Print("");
}
om (bränsle > = 87) {
lcd.setCursor(17,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(17,3);
LCD.Print("");
}
om (bränsle > = 92) {
lcd.setCursor(18,3);
LCD.Print (2, BYTE).
} annat {
lcd.setCursor(18,3);
LCD.Print("");
}
om (bränsle > = 96) {
lcd.setCursor(19,3);
LCD.Print("F");
} annat {
lcd.setCursor(19,3);
LCD.Print("");
}
fördröjning (50);
}