Arduino
Arduino
h"
#define NEOPIXEL_MINUTE_PIN 2
#define NEOPIXEL_HOUR_PIN 3
#define AM_PM_PIN1 4
#define AM_PM_PIN0 5
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
String password = ""; // Our virtual wifi has no password (so dont do your banking stuff on this network)
int setupESP8266(void) {
if (!Serial.find("OK")) return 1;
if (!Serial.find("OK")) return 2;
if (!Serial.find("OK")) return 3;
return 0;
}
long getTimeESP8266(void) {
String httpPacket = "GET " + uri + " HTTP/1.1\r\nHost: " + host + "\r\n\r\n";
Serial.print("AT+CIPSEND=");
Serial.println(length);
Serial.print(httpPacket);
while(!Serial.available()) delay(5); // wait until we receive the response from the server
if (Serial.find("\r\n\r\n")) { // search for a blank line which defines the end of the http header
delay(5);
char c = Serial.read();
if(c=='"') break; // break out of our loop because we got all we need
i++;
delay(1);
outputString.remove(outputString.length() - 6);
return outputString.toInt();
int sychronizeTime(void) {
drawHourHand(-1);
if (now >= 0) {
now /= 60;
now /= 60;
void setPixelColor(Adafruit_NeoPixel& strip, int index, unsigned char red, unsigned char green, unsigned
char blue, int brightness = 256) {
strip.setPixelColor(
index,
);
void drawMinuteHand(void) {
stripMinute.clear();
int index;
int i;
stripMinute.show();
stripHour.clear();
if (sweep < 0) {
} else {
if (hour12 == sweep) {
} else {
stripHour.show();
void updateClock(void) {
if (++count == 24) {
count = 0;
minute = 0;
second = 0;
drawMinuteHand();
// Update AM/PM
digitalWrite(AM_PM_PIN0, LOW);
ISR(TIMER2_COMPA_vect) {
count += 24;
count -= 125;
updateClock();
}
void setup() {
digitalWrite(AM_PM_PIN0, HIGH);
pinMode(AM_PM_PIN0, OUTPUT);
digitalWrite(AM_PM_PIN1, HIGH);
pinMode(AM_PM_PIN1, OUTPUT);
stripMinute.begin();
stripHour.begin();
setupESP8266();
sychronizeTime();
drawMinuteHand();
TIFR2 = 0x00; //Timer2 INT Flag Reg: Clear Timer Overflow Flag
void loop() {
sychronizeTime();
lastSecond = second;
delay(100);