本文整理汇总了C++中LiquidCrystal类的典型用法代码示例。如果您正苦于以下问题:C++ LiquidCrystal类的具体用法?C++ LiquidCrystal怎么用?C++ LiquidCrystal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LiquidCrystal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loop
void loop()
{
if (checkRFID())
{
Serial.end();
lcd.clear();
switch (restaurantCode)
{
case 0:
break; //shouldn't get here...
case 1:
{
lcd.clear();
lcd.print("~Chipotle Menu");
}
default:
break;
}
delay(1000);
char select = priceSelect();
lcd.clear();
lcd.print("Selected: ");
switch (select)
{
case 0:
{
lcd.print("$1-5");
break;
}
case 1:
{
lcd.print("$5-10");
break;
}
case 2:
{
lcd.print("$10-15");
break;
}
case 3:
{
lcd.print("$15+up");
break;
}
default:
break; //shouldnt get here;
}
delay(1000);
lcd.clear();
lcd.print("at Chipotle");
delay(2000);
moneyPacketAdd(select);
restPacketAdd(restaurantCode);
sendPacket();
lcd.clear();
lcd.print("Request sent!");
getPacket();
parseInPacket();
lcd.clear();
int mealSelection = mealSelect();
if (mealSelection == 100)
{
lcd.clear();
lcd.print("Com Errors!");
delay(5000);
hardReset();
}
addPacketFood(mealSelection);
sendPacket();
lcd.clear();
lcd.print("Order sent!");
delay(3000);
lcd.clear();
lcd.print("-RFID Menu Scan-");
digitalWrite(RFID_ENABLE, LOW);
Serial.begin(2400);
Serial.flush();
}
delay(500);
}
示例2: loop
void loop() {
statoPulsante = digitalRead(6);
if(statoPulsante != precedenteStatoPulsante)
if (statoPulsante == LOW) {
risposta = random(8);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("La Palla dice:");
lcd.setCursor(0,1);
switch(risposta) {
case 0: lcd.print("Si"); break;
case 1: lcd.print("Molto probabilmente"); break;
case 2: lcd.print("Certamemte"); break;
case 3: lcd.print("Sembra di si"); break;
case 4: lcd.print("Insicuro"); break;
case 5: lcd.print("Domanda ancora"); break;
case 6: lcd.print("Molto dubbio"); break;
case 7: lcd.print("NO"); break;
};
};
precedenteStatoPulsante = statoPulsante;
}
示例3: loop
void loop() {
static bool show_warning = false;
int result = dht11.read();
switch (result) {
case Dht11::OK:
Serial.println("Read ok");
break;
case Dht11::ERROR_TIMEOUT:
Serial.println("Timeout");
return;
case Dht11::ERROR_CHECKSUM:
Serial.println("Checksum error");
return;
default:
Serial.println("WTF?");
return;
}
lcd.setCursor(0, 0);
lcd.print("T: ");
// lcd.print(dht11.getTemperature());
// lcd.print(" | ");
// We trust more the thermistor than the humidity sensor...
// The last one was giving **really** unrealistic results.
float temperature = Tmp36AvgTemperature();
lcd.print(temperature, 2);
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print("Hum: ");
lcd.print(dht11.getHumidity());
lcd.print('%');
if (temperature > TEMPERATURE_MAX ||
temperature < TEMPERATURE_MIN)
show_warning = !show_warning;
else
show_warning = false;
lcd.setCursor(LCD_COLS - 3, 0);
if (show_warning)
lcd.print("(!)");
else
lcd.print(" ");
delay(500);
}
示例4: off
void off() {
lcd.noDisplay();
led.off();
}
示例5: initLCD
// Simple clearing of LCD screen while simultaneously
// updating the col and row trackers
// col, row: pointers to locations on LCD
void CurveInput::initLCD( byte* col, byte* row )
{
lcd.clear();
*col = 0; *row = 0;
lcd.setCursor(*col, *row);
}
示例6: loop
void loop(){
if(gameFinished == false){
float time_to = random(1,2); //.. Aantal milliseconde om mee te beginnen
int i;
float current_multiplier = 0.98;
float cashedOutMultiplier;
int randomNumber = random(0,1000);
if(randomNumber < 201){
randomNumber = 0;
}
for(i = 0; i <= randomNumber; i++){
switch (lcd_key){
case btnSELECT:{
cashedOut = true;
cashedOutMultiplier = current_multiplier;
break;
}}
lcd.clear();
lcd.print("BustaDuino"); // print a simple message on the LCD
lcd.setCursor(0, 1);
if(randomNumber > 0){
current_multiplier = current_multiplier + 0.01;
}else{
current_multiplier = 0;
}
lcd.print(String(current_multiplier) + "x");
Serial.print(String(current_multiplier) + "x");
lcd_key = read_LCD_buttons(); // read the buttons
if(i <= randomNumber && cashedOut == true){
lcd.clear();
lcd.print("You Win!");
lcd.setCursor(0, 1);
lcd.print(String(cashedOutMultiplier) + "x");
Serial.print(String(cashedOutMultiplier) + "x");
gameFinished = true;
break;
}else if(i >= randomNumber && cashedOut == false){
lcd.clear();
lcd.print("BUSTED!");
lcd.setCursor(0, 1);
lcd.print(String(current_multiplier) + "x");
Serial.print(String(current_multiplier) + "x");
gameFinished = true;
}
delay((time_to/i) * 3000);
}
}
}
示例7: loop
void loop()
{
int value = analogRead(0);
Serial.print ( itoa ( value, buffer, 10 ) );
int key = keypad.getKey();
// wake up
if ( key != NO_KEY && mode == LOW_POWER_MODE )
{
mode = NORMAL_MODE;
}
switch ( key )
{
case NO_KEY:
keyPressed = 0;
if ( mode != SET_FEED_MODE )
{
if ( prevKey == DOWN_KEY )
{
feedIndex++;
if (feedIndex == 5)
feedIndex = 1;
showFeedTime(feedIndex);
}
else if ( prevKey == UP_KEY )
{
feedIndex--;
if ( feedIndex == 0 )
feedIndex = 4;
showFeedTime(feedIndex);
}
}
prevKey = NO_KEY;
break;
case SELECT_KEY:
Serial.println("Select");
if ( mode == SET_CLOCK_MODE && keyPressed == 0 )
{
Serial.println("Leaving edit mode");
mode = NORMAL_MODE;
//RTC.isMEZSummerTime();
Serial.print(RTC.day);
Serial.print(RTC.month);
Serial.print(RTC.year);
Serial.print(RTC.hour);
Serial.print(RTC.minute);
Serial.print(RTC.dow);
RTC.second = 0;
RTC.setTime();
RTC.startClock();
}
else if ( mode == SET_FEED_MODE && keyPressed == 0 )
{
Serial.println("Leaving set feed mode");
storeFeedTime(feedIndex);
showFeedTime(feedIndex);
mode = NORMAL_MODE;
}
else
{
// enter set clock mode after select key is long pressed
keyPressed++;
if ( keyPressed == 10 )
{
Serial.println("Entering edit mode");
mode = SET_CLOCK_MODE;
//keyPressed = 0;
prevKey = NO_KEY;
position = POS_DAY;
RTC.stopClock();
lcd.setCursor(0, 0);
}
}
break;
case RIGHT_KEY:
Serial.println("Right");
// set position to set clock
if ( mode == SET_CLOCK_MODE )
{
switch ( position )
{
case POS_DAY:
position = POS_MONTH;
break;
case POS_MONTH:
//.........这里部分代码省略.........
示例8: setup
void setup() {
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
示例9: loop
void loop()
{
int i;
while (RFID.available() <= 0); // force wait until rfid present
if(RFID.available() > 0) //does rfid exist?
{
i = 0;
while (i < 14)
{
tag_id = RFID.read(); //Reads character, puts into tag_id
if (tag_id == '-1') //Wait for scan to read
continue;
id_string = String(id_string + tag_id); //Make it a string
//TESTING OUTPUT
//For some reason, getting rid of this makes the tag not read correctly
Serial.print("Read: ");
Serial.print(tag_id);
Serial.print("\nid_string is now ");
Serial.print(id_string);
i++; //counts up unil 14
}
//TESTING OUTPUT
Serial.print("\nid_string is now ");
Serial.print(id_string);
for(int index=0; index<5; index++) //first we check to see if there are any current matches
{
if(id_string == id_array[index]) //if the id matches something in the array at location "i"
{
Serial.println("Match"); //print that it matches.
id_array[index] = String(""); //set the array location of the removed tag to blank
if (id_marker[index] == 1) //if the id marker is equal to one
//else //Removing this else because I dont think it makes sense.
{
// space_left++; //this isnt properly increasing the spaces left
//Commented out space left above because theres also one below.
// not sure if this is necessary
for (int j = index; j < 4; j++) //what purpose does j serve? Increments the search?
{
id_string[j] = id_string[j + 1];
id_marker[j] = id_marker[j + 1];
Serial.println(id_marker[index]); //test print for the current marker.
}
index--; //this might actually only subtract the last place, and not the proper location
space_left++;
no_match = 1;
}
}
}//End of for loop
//I added the ifs below to attempt to refine the location of the write location in the array. they dont work completely
if (no_match == 0)
{
if (id_array[index] != String("")) //if the array location is not blank, then
{
index ++; //increment to the next spot
Serial.println(i);
}
if (index == 5) //if we're at the 5th spot
{
index = 0; //start back at zero
}
//this needs to be able to detect black values
id_array[index] = id_string;
id_marker[index]++;
space_left--;
}
}
Serial.println(" "); // prints a space
Serial.println(id_array[index]); // print the array item
Serial.println("Finished Reading ID."); //prints out this on a line
Serial.print("There are "); //start printing the result
Serial.print(space_left); //then how many spaces
Serial.print(" spaces left."); //words
Serial.println(" "); //spaces
//lcd output
lcd.clear();
lcd.print("There are "); //start printing the result
//.........这里部分代码省略.........
示例10: running
//===============================================================================
void running() {
if(programed == true) {
switch(statea) {
case 1:
lcd.setCursor(0, 0);
lcd.print(" Armed ");
lcd.setCursor(0, 1);
if((keyBool == true) && (keyDis != true)) {
lcd.print("K=");
if((digitalRead(largeKey) == HIGH) && (lKey == true)) {
keyDis = true;
lcd.print("D");
}
else if((digitalRead(largeKey) == LOW) && (lKey == false)) {
keyDis = true;
lcd.print("D");
}
else
lcd.print("A");
}
if((keypadBool == true) && (keypadDis != true)) {
but = keypadA.getKey();
if((but != NO_KEY) && (i < 4)) {
butt[i] = but;
i++;
if(i == 4) {
if((code[0] == butt[0]) && (code[1] == butt[1]) && (code[2] == butt[2]) && (code[3] == butt[3]))
keypadDis = true;
else {
butt[0] = '-';
butt[1] = '-';
butt[2] = '-';
butt[3] = '-';
i = 0;
if(attem == true) {
attemCount--;
if(attemCount == 0) {
bang = true;
}
}
}
}
but = '-';
}
lcd.print(butt[0]);
lcd.print(butt[1]);
lcd.print(butt[2]);
lcd.print(butt[3]);
lcd.print(" ");
lcd.print(attemCount);
}
if(wireBool == true) {
if((digitalRead(wire1) == LOW) && (safeWire == 1))
wireDis = true;
else if((digitalRead(wire1) == LOW) && (safeWire != 1))
bang = true;
if((digitalRead(wire2) == LOW) && (safeWire == 2))
wireDis = true;
else if((digitalRead(wire2) == LOW) && (safeWire != 2))
bang = true;
if((digitalRead(wire3) == LOW) && (safeWire == 3))
wireDis = true;
else if((digitalRead(wire3) == LOW) && (safeWire != 3))
bang = true;
if((digitalRead(wire4) == LOW) && (safeWire == 4))
wireDis = true;
else if((digitalRead(wire4) == LOW) && (safeWire != 4))
bang = true;
}
if(bang == true) {
statea = 3;
}
if((wireDis == true) || ((keyDis == keyBool) && (keypadDis == keypadBool))) {
statea = 2;
}
break;
case 2://Disarmed
lcd.setCursor(0, 0);
lcd.print(" Disarmed ");
lcd.setCursor(0, 1);
lcd.print(" ");
break;
case 3://Bang
lcd.setCursor(0, 0);
lcd.print(" BANG ");
lcd.setCursor(0, 1);
//.........这里部分代码省略.........
示例11: program
//===============================================================================
void program() {
switch(progState) {
case 0:
lcd.setCursor(0,0);
lcd.print("Use keypad ? ");
lcd.setCursor(0,1);
lcd.print("*-Yes #-No");
programed = false;
but = keypadA.getKey();
if (but == '#') {
keypadBool = false;
progState = 1;
but = NO_KEY;
}
else if (but == '*') {
keypadBool = true;
progState = 1;
but = NO_KEY;
}
break;
//----------------------------------------------------------------------
case 1:
lcd.setCursor(0,0);
lcd.print("Use key ? ");
lcd.setCursor(0,1);
lcd.print("*-Yes #-No");
but = keypadA.getKey();
if (but == '#') {
keyBool = false;
progState = 2;
but = NO_KEY;
}
else if (but == '*') {
keyBool = true;
progState = 2;
but = NO_KEY;
}
break;
//----------------------------------------------------------------------
case 2:
lcd.setCursor(0,0);
lcd.print("Use Wires ? ");
lcd.setCursor(0,1);
lcd.print("*-Yes #-No");
but = keypadA.getKey();
if (but == '#') {
wireBool = false;
progState = 3;
but = NO_KEY;
}
else if (but == '*') {
wireBool = true;
progState = 3;
but = NO_KEY;
}
break;
//----------------------------------------------------------------------
case 3:
lcd.setCursor(0,0);
lcd.print("Use Timer ? ");
lcd.setCursor(0,1);
lcd.print("*-Yes #-No");
but = keypadA.getKey();
if (but == '#') {
timerBool = false;
progState = 4;
but = NO_KEY;
}
else if (but == '*') {
timerBool = true;
progState = 4;
but = NO_KEY;
}
break;
//----------------------------------------------------------------------
case 4:
lcd.setCursor(0,0);
lcd.print("KP-");
lcd.print(keypadBool);
lcd.print("Ky-");
lcd.print(keyBool);
lcd.print("W-");
lcd.print(wireBool);
//.........这里部分代码省略.........
示例12: if
boolean RF22Mesh::recvfromAck(uint8_t* buf, uint8_t* len, uint8_t* source, uint8_t* dest, uint8_t* id, uint8_t* flags)
{
uint8_t tmpMessageLen = sizeof(_tmpMessage);
uint8_t _source;
uint8_t _dest;
uint8_t _id;
uint8_t _flags;
uint8_t frags = 0;
uint8_t offset = 0;
uint8_t total_len = 0;
uint8_t seq_no = 0;
uint8_t x = 0, y = 0;
uint8_t loop_once = 1;
uint8_t have_message = 0;
#ifndef CLIENT
lcd.begin( 20, 4 );
lcd.clear();
#endif
while( frags > 0 || loop_once == 1 ) {
loop_once = 0;
if (RF22Router::recvfromAck(_tmpMessage, &tmpMessageLen, &_source, &_dest, &_id, &_flags))
{
MeshMessageHeader* p = (MeshMessageHeader*)&_tmpMessage;
if ( tmpMessageLen >= 1
&& p->msgType == RF22_MESH_MESSAGE_TYPE_APPLICATION)
{
have_message = 1;
MeshApplicationMessage* a = (MeshApplicationMessage*)p;
// Handle application layer messages, presumably for our caller
if (source) *source = _source;
if (dest) *dest = _dest;
if (id) *id = _id;
if (flags) *flags = _flags;
uint8_t msgLen = tmpMessageLen - sizeof(MeshMessageHeader);
if (*len > msgLen)
*len = msgLen;
frags = a->header.frag;
#ifdef CLIENT
Serial.print( F( "RF22Mesh::recvfromAck frags: " ) );
Serial.println( frags );
#endif
seq_no = a->header.seqno;
if( frags > 0 || (frags == 0 && a->header.seqno > 0 ) ) {
offset = a->header.seqno * RF22_MESH_MAX_MESSAGE_LEN;
}
#ifdef CLIENT
for( int i = 0; i < *len; i++ ) {
Serial.print( a->data[i] );
Serial.print( F( ", " ) );
}
Serial.println( F( "" ) );
#endif
memcpy( buf + offset, a->data, *len );
#ifndef CLIENT
lcd.setCursor( x, y );
lcd.print( *len );
if( ( x + 8 ) > 20 ) {
y++;
x = 0;
} else {
x += 4;
}
#endif
}
else if ( _dest == RF22_BROADCAST_ADDRESS
&& tmpMessageLen > 1
&& p->msgType == RF22_MESH_MESSAGE_TYPE_ROUTE_DISCOVERY_REQUEST)
{
MeshRouteDiscoveryMessage* d = (MeshRouteDiscoveryMessage*)p;
// Handle Route discovery requests
// Message is an array of node addresses the route request has already passed through
// If it originally came from us, ignore it
if (_source == _thisAddress)
return false;
uint8_t numRoutes = tmpMessageLen - sizeof(MeshMessageHeader) - 2;
uint8_t i;
// Are we already mentioned?
for (i = 0; i < numRoutes; i++)
if (d->route[i] == _thisAddress)
return false; // Already been through us. Discard
// Hasnt been past us yet, record routes back to the earlier nodes
addRouteTo(_source, headerFrom()); // The originator
for (i = 0; i < numRoutes; i++)
addRouteTo(d->route[i], headerFrom());
if (isPhysicalAddress(&d->dest, d->destlen))
//.........这里部分代码省略.........
示例13: loop
void loop() {
lcd.print("Minutes: ");
lcd.setCursor(0,1);
lcd.blink();
while (selectmin == true) {
lcd_key = read_LCD_buttons();
switch (lcd_key) {
case btnRIGHT:
break;
case btnLEFT:
break;
case btnUP: {
minutes = minutes + 1;
lcd.setCursor(0,1);
lcd.print(minutes);
break;
}
case btnDOWN: {
if (minutes > 0) {
minutes = minutes - 1;
lcd.setCursor(0,1);
lcd.print(minutes);
}
break;
}
case btnSELECT: {
selectmin = false;
break;
}
case btnNONE:
break;
}
delay(200);
}
lcd.clear();
delay(500);
lcd.print("Seconds: ");
lcd.setCursor(0,1);
lcd.blink();
while (selectsec == true) {
lcd_key = read_LCD_buttons();
switch (lcd_key) {
case btnRIGHT:
break;
case btnLEFT:
break;
case btnUP: {
if (seconds == 59) {
seconds = 0;
} else {
seconds = seconds + 1;
}
lcd.setCursor(0,1);
lcd.print(seconds);
break;
}
case btnDOWN: {
if (seconds > 0) {
seconds = seconds - 1;
} else if (seconds == 0) {
seconds = 59;
}
lcd.setCursor(0,1);
lcd.print(seconds);
}
break;
}
case btnSELECT: {
selectsec = false;
break;
}
case btnNONE:
break;
}
}
示例14: setup
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
}
示例15: Print
// Prints a string to the LCD display, with an optional integer value beside it
inline void Print(String text, int value = -1)
{
lcd.print(text);
if (value != -1) lcd.print(value);
}