Created
June 20, 2013 16:29
-
-
Save shvelo/5824308 to your computer and use it in GitHub Desktop.
Arduino Mega2560 |
Library: https://github.com/rodan/ds3231 |
Pins: SDA to Pin20 |
SCL to Pin21 |
VCC to 5v |
GND to GND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// include the library code: | |
#include <LiquidCrystal.h> | |
#include <Wire.h> | |
#include "ds3231.h" | |
// initialize the library with the numbers of the interface pins | |
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
int sensorValue; | |
byte full[8] = { | |
B11111, | |
B11111, | |
B11111, | |
B11111, | |
B11111, | |
B11111, | |
B11111, | |
}; | |
byte empty[8] = { | |
B00000, | |
B00000, | |
B00000, | |
B00000, | |
B00000, | |
B00000, | |
B00000, | |
}; | |
void setup() { | |
lcd.createChar(0, empty); | |
lcd.createChar(1, full); | |
lcd.begin(16, 2); | |
pinMode(A0, INPUT); | |
digitalWrite(A0, HIGH); | |
Serial.begin(19200); | |
Wire.begin(); | |
DS3231_init(0x06); | |
} | |
void loop() { | |
struct ts now; | |
DS3231_get(&now); | |
char time[5]; | |
sprintf(time,"%02d:%02d", now.hour, now.min); | |
lcd.setCursor(0, 0); | |
lcd.print(time); | |
sensorValue = analogRead(A0) / 64; | |
for(int i = 0; i < 16; i++) { | |
lcd.setCursor(i, 1); | |
if(i <= sensorValue + 1) lcd.write(byte(1)); | |
else lcd.write(byte(0)); | |
} | |
delay(80); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment