// LCD1602 to Arduino Uno connection example
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
byte dummy[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000
};
byte heart[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000
};
byte smiley[8] = {
0b00000,
0b00000,
0b01010,
0b00000,
0b00000,
0b10001,
0b01110,
0b00000
};
byte frownie[8] = {
0b00000,
0b00000,
0b01010,
0b00000,
0b00000,
0b00000,
0b01110,
0b10001
};
byte armsDown[8] = {
0b00100,
0b01010,
0b00100,
0b00100,
0b01110,
0b10101,
0b00100,
0b01010
};
byte armsUp[8] = {
0b00100,
0b01010,
0b00100,
0b10101,
0b01110,
0b00100,
0b00100,
0b01010
};
//Constant frequency of beep note
#define Beep 1100
//This is the signaling pin for buzzer
#define SPEAKER_PIN 13
//const uint8_t buttonPins[] = {3, 4, 5, 6};
void setup() {
Serial.begin(115200);
//Serial.println(F("Serial iniciada!"));
//Initializing pin 13 as Output
pinMode(SPEAKER_PIN, OUTPUT);
preparaBotao();
preparaLed();
// create a new character
lcd.createChar(1, heart);
// create a new character
lcd.createChar(2, smiley);
// create a new character
lcd.createChar(3, frownie);
// create a new character
lcd.createChar(4, armsDown);
// create a new character
lcd.createChar(5, armsUp);
lcd.clear();
// Turn off the display:
lcd.noDisplay();
delay(500);
// Turn on the display:
lcd.display();
lcd.begin(16, 2);
// you can now interact with the LCD, e.g.:
// play the second
tone(SPEAKER_PIN, Beep);
// wait 100ms
delay(100);
// stop the sound
noTone(SPEAKER_PIN);
lcd.setCursor(0,0);
lcd.print("Smart Home");
Serial.println("Smart Home");
lcd.setCursor(0,1);
lcd.print("Application");
Serial.println("Application");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("LCD 16x2 Char");
Serial.println("LCD 16x2 Char");
lcd.setCursor(0,1);
lcd.print("Test Started");
Serial.println("Test Started");
delay(2000);
lcd.begin(16, 2);
lcd.setCursor(0,0);
for (int Lin1 = 0; Lin1 < 16; Lin1++) {
lcd.print("#");
Serial.print("#");
setFlag(!getFlag());
verificaFlag();
delay(200);
}
Serial.println();
lcd.setCursor(0, 1);
for (int Lin2 = 0; Lin2 < 16; Lin2++) {
lcd.print("#");
Serial.print("#");
setFlag(!getFlag());
verificaFlag();
delay(200);
}
Serial.println();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Test Finished!");
Serial.println("Test Finished!");
lcd.setCursor(0, 1);
lcd.print("Time ");
Serial.print("Time ");
lcd.print(millis() / 1000);
Serial.print(millis() / 1000);
lcd.print("sec");
Serial.println("sec");
delay(1000);
// ...
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("System Ready");
Serial.print("System Ready :)");
Serial.println();
//lcd.setCursor(0, 1);
//lcd.print("Waiting data...");
// play the second
tone(SPEAKER_PIN, Beep);
// wait 100ms
delay(100);
// stop the sound
noTone(SPEAKER_PIN);
// set the cursor to the top row, 14th position:
lcd.setCursor(13, 0);
// draw the smile:
lcd.write(2);
delay(10);
}
void loop() {
//lcd.setCursor(8, 1);
// draw the time in milliseconds:
//lcd.print(millis() / 1000);
//lcd.print(" sec");
verificaBotao();
verificaFlag();
}