/* i2c LCD control for 16x2.
* Tutorial: http://www.electronoobs.com/eng_arduino_tut51.php
* Tutorial: http://www.electronoobs.com/eng_arduino_tut51_sch1.php
*/
//LCD config
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <OneWire.h> //for temp sensor
#include <DallasTemperature.h> //for temp sensor
LiquidCrystal_I2C lcd(0x27,20,4); //sometimes the LCD adress is not 0x3f. Change to 0x27 if it dosn't work.
int i = 0;
int counter = 0; //fejkvariabel för att simulera räkning
// Data wire is conntec to the Arduino digital pin 4
#define ONE_WIRE_BUS 7
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
//My own characters
uint8_t ball1[8] = {B00000, B00000,B00100,B01110,B01110,B00100,B00000,B00000};
uint8_t battery1[8] = {
B00100,
B01110,
B10001,
B10001,
B10001,
B10001,
B10001,
B11111
};
uint8_t battery2[8] = {
B00100,
B01110,
B10001,
B10001,
B10001,
B10001,
B11111,
B11111
};
void setup() {
lcd.init(); //Init the LCD
lcd.backlight(); //Activate backlight
sensors.begin();
sensors.setResolution(9);
Serial.begin(9600);
//Create own characters
lcd.createChar(0, ball1);
}
void loop() {
sensors.requestTemperatures(); // Call sensors.requestTemperatures()
float tempCelcius = sensors.getTempCByIndex(0);
int tempNoDecimals = (int)tempCelcius; //Ta bort decimalerna
static bool oneTime = false;
static int counter = 0;
/*test av custom character
byte customChar[] = {
B00000,
B00000,
B00100,
B01110,
B01110,
B00100,
B00000,
B00000
};
if(!oneTime){
// Turn off the display:
lcd.clear();
lcd.print(" Animate");
lcd.setCursor(0,1);
lcd.print(" Test");
oneTime = true;
delay(2000);
lcd.clear();
}
*/
/* for(int i = 0; i <=16; i++){
lcd.setCursor(i,0);
lcd.print("O");
delay(500);
}
for(int j = 0; j <=16; j++){
lcd.setCursor(j,0);
lcd.print("o");
}
for (int i = 0, j = 0, k = 0; i <= 16 || j <= 16 || k <= 16; i++, j++, k++) {
if (i <= 16) {
lcd.setCursor(i, 0); // Första "O" på rad 0
lcd.print("O");
delay(100);
}
if (j <= 16) {
lcd.setCursor(j, 0); // Andra "o" på rad 1
lcd.print("o");
delay(100);
}
if (k <= 16) {
lcd.setCursor(j, 0); // Andra "o" på rad 1
lcd.print(" ");
delay(100);
}
*/
lcd.setCursor(0, 0);
lcd.write(0);
delay(100);
lcd.setCursor(0, 0);
lcd.print("o");
delay(100);
lcd.setCursor(0, 0);
lcd.print("_");
delay(100);
lcd.setCursor(0, 0);
lcd.print("o");
delay(100);
}