Alison Yang
Published © GPL3+

Time By Wind

The sound of the bells would echo for a long time, with a tingling crisp sound, and this was what inspired me to make a wind chime clock.

BeginnerFull instructions provided8 hours75
Time By Wind

Things used in this project

Hardware components

Seeed Grove Beginner Kit
×1
Seeed Grove - RGB LED Ring (20 - WS2813 Mini)
×1
Grove - RTC
Seeed Grove - RTC
×1
Wooden Board
×1
Fibre Optic Cable
×20
Shadowless UV glue
×1
Bell
×1
String
×1

Software apps and online services

Arduino IDE
Arduino IDE
Fusion 360
Autodesk Fusion 360

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Code

alice-demo.ino

C/C++
#include <FlexiTimer2.h>
#include "Adafruit_NeoPixel.h"
#include <Wire.h>
#include "rgb_lcd.h"
#include <DS1307.h>
#include <rgb_lcd.h>

#define BUTTON_PIN   2  
#define PIXEL_PIN    6    // Digital IO pin connected to the NeoPixels.
#define PIXEL_COUNT 20

#define T 60000

int touch_flag = 0;
long Time = 0;
int i = 0;

int frist_time = 0;

DS1307 clock;
rgb_lcd lcd;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
 
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    if(touch_flag != 1)
    {
    for(i=0; i< strip.numPixels(); i++) {
      if(touch_flag != 1)
      {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
      }else{break;}
      Serial.println();
    }
    }else{break;}
    strip.show();
    clock.getTime();
    lcd.setCursor(4, 1);
    lcd.print(clock.hour, DEC);
    lcd.print(":");
    lcd.print(clock.minute, DEC);
    lcd.print(":");
    if(clock.second < 10)
    {
      lcd.print(0,DEC);
      lcd.print(clock.second, DEC); 
    }else
    {
      lcd.print(clock.second, DEC);
    }
    delay(wait);
  }
}

void scan()
{
  if(digitalRead(5)==HIGH)
  {
    delay(10);
    if(digitalRead(5)==HIGH)
    touch_flag = 1;
    Serial.println("iii");
  }
}

void setup()
{
  Serial.begin(115200);
  pinMode(5,INPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  strip.setBrightness(255);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  FlexiTimer2::set(5, 1.0/1000, scan);
  FlexiTimer2::start();
  lcd.begin(16, 2);
  lcd.setCursor(1, 0);
  lcd.print("hello, beauty!");
  clock.begin();
 }

void loop()
{
   if(touch_flag == 1)
   {
      if(frist_time == 0)
      {
        for(int i = 0;i<20;++i)
        {
          strip.setPixelColor(i, strip.Color(0,0,0));
          strip.show();
        }
        lcd.setCursor(0, 1);
        lcd.print("                ");
        frist_time = 1;
        ++i;
        strip.setPixelColor(i, strip.Color(255,59,70));
        Time = millis();
      }
      if(i < 20 && millis()-Time >= T/20)
      {
        strip.setPixelColor(i, strip.Color(255,59,70));
        strip.show();
        Time = millis();
        ++i;
      }else if(i>=20)
      {
        i = 0;
        frist_time = 0;
        Time = 0;
        touch_flag = 0;
      }
   }else
   {
    rainbowCycle(0);
   }
   clock.getTime();
    lcd.setCursor(7, 1);
    if(clock.second < 10)
    {
      lcd.print(0,DEC);
      lcd.print(clock.second, DEC); 
    }else
    {
      lcd.print(clock.second, DEC);
    }
}

Credits

Alison Yang

Alison Yang

1 project • 1 follower

Comments

Add projectSign up / Login