Étape 7: programmation
LiquidCrystal.h http://arduino.cc/en/Tutorial/LiquidCrystalCapSense.h http://www.arduino.cc/playground/Main/CapSensecopie et au-delà de cela dans l’Arduino 0017 ou plus récent.
Capteur capacitif de Liquid
Vadim 7 décembre 2009
#include
#include
Il s’agit de définir la taille de l’écran lcd
const int numRows = f = 4 ;
const int numCols = 20 ;
Cette commande définit les broches pour l’écran lcd (RS, activer, données 0-7)
Innovente lcd (53, 52, 51, 50, 49, 48,47,46,45,44) ;
#define tempin 0 x 48
#define Tempout 0 x 49
CapSense cs_22_23 = CapSense(22,23) ;
uint8_t bloc [8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} ;
uint8_t tl [8] = {0x0F, 0 x 08, 0 x 08, 0 x 08, 0 x 08, 0 x 08, 0x0F, 0x0F} ;
uint8_t tr [8] = {0 x 16, 0 x 11, 0 x 11, 0 x 11, 0 x 11, 0 x 11, 0x1D, 0 x 15} ;
uint8_t bl [8] = {0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x1F} ;
uint8_t br [8] = {0 x 15, 0 x 15, 0 x 15, 0 x 15, 0 x 15, 0 x 15, 0 x 12, 0 x 18} ;
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 octets) ;
lcd.setCursor(19,0) ;
LCD.Print octet (5) ;
lcd.setCursor(18,1) ;
LCD.Print (6 octets) ;
lcd.setCursor(19,1) ;
LCD.Print (7 octets) ;
lcd.setCursor(0,2) ;
LCD.Print (« carburant ») ;
lcd.setCursor(0,3) ;
LCD.Print("E") ;
}
void loop() {}
carburant longue ;
lcd.createChar (bloc 2) ;
commencer à long = millis() ;
carburant = cs_22_23.capSenseRaw(200) ;
Temratue fait un peu d’un difrence alors laisser tourner pendant 5 min avant la mise au point.
Ajuster ce nombre afin que la sortie est plus près de zéro que possible.
carburant = essence - 7200 ;
Puis remplir le conataner
Un commentaire et régler cela afin que la sortie, quand le réservoir est plein,
est aussi proche de 100 que possible.
carburant = essence / 93 ;
lcd.setCursor(0,0) ;
LCD.Print("") ;
lcd.setCursor(0,0) ;
LCD.Print(Fuel) ;
Si (carburant > = 6) {}
lcd.setCursor(1,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(1,3) ;
LCD.Print("") ;
}
Si (carburant > = 12) {}
lcd.setCursor(2,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(2,3) ;
LCD.Print("") ;
}
Si (carburant > = 17) {}
lcd.setCursor(3,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(3,3) ;
LCD.Print("") ;
}
Si (carburant > = 23) {}
lcd.setCursor(4,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(4,3) ;
LCD.Print("") ;
}
Si (carburant > = 28) {}
lcd.setCursor(5,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(5,3) ;
LCD.Print("") ;
}
Si (carburant > = 34) {}
lcd.setCursor(6,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(6,3) ;
LCD.Print("") ;
}
Si (carburant > = 39) {}
lcd.setCursor(7,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(7,3) ;
LCD.Print("") ;
}
Si (carburant > = 44) {}
lcd.setCursor(8,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(8,3) ;
LCD.Print("") ;
}
Si (carburant > = 50) {}
lcd.setCursor(9,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(9,3) ;
LCD.Print("") ;
}
Si (carburant > = 55) {}
lcd.setCursor(10,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(10,3) ;
LCD.Print("") ;
}
Si (carburant > = 60) {}
lcd.setCursor(11,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(11,3) ;
LCD.Print("") ;
}
Si (carburant > = 64) {}
lcd.setCursor(12,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(12,3) ;
LCD.Print("") ;
}
Si (carburant > = 69) {}
lcd.setCursor(13,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(13,3) ;
LCD.Print("") ;
}
Si (carburant > = 74) {}
lcd.setCursor(14,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(14,3) ;
LCD.Print("") ;
}
Si (combustible > = 78) {}
lcd.setCursor(15,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(15,3) ;
LCD.Print("") ;
}
Si (carburant > = 83) {}
lcd.setCursor(16,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(16,3) ;
LCD.Print("") ;
}
Si (carburant > = 87) {}
lcd.setCursor(17,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(17,3) ;
LCD.Print("") ;
}
Si (carburant > = 92) {}
lcd.setCursor(18,3) ;
LCD.Print (2 octets) ;
} else {}
lcd.setCursor(18,3) ;
LCD.Print("") ;
}
Si (carburant > = 96) {}
lcd.setCursor(19,3) ;
LCD.Print("F") ;
} else {}
lcd.setCursor(19,3) ;
LCD.Print("") ;
}
retard (50) ;
}