Coin Farm ( Busco afiliados para jugar)

Mostrando entradas con la etiqueta Timbre automatico. Mostrar todas las entradas
Mostrando entradas con la etiqueta Timbre automatico. Mostrar todas las entradas

lunes, 9 de mayo de 2016

Timbre automatico

Para los interesados en el timbre automático que estoy haciendo les dejo el código para la placa Arduino Uno (lo probe con la Mega y la Nano).Por el pin 13 comando una placa Relay.
Para ver su funcionamiento hago un reporte serial
Por cualquier información pueden escribirme a olafvgb61@gmail.com

/******************************************************************
* Autor  : Olaf Albrecht                                          *
* Release             : 2.0                                       *
* Soft.Date           : 20 junio, 2015                            *
* Fecha Nuevo Release : 13 mayo , 2016                            *
* Comments            : Compara con el reloj la hora y minutos    *
*                       y activa un Relay para disparar un timbre *
*                                                                 *
* Hardware Used    : - Arduino Uno R-3 module                     *
*                    - Display LCD Arduino Compatible (LCD 16x2)  *
*                    - Display (Hitachi HD44780 driver).          *
*                    - RTC Reloj base de tiempo                   *
*******************************************************************
*/
#include <Wire.h>
#include <LiquidCrystal.h>
#include "RTClib.h"
RTC_DS1307 RTC;
LiquidCrystal lcd(8, 7, 12, 11, 10,9);
int dia;
int seg;
int HORMIL;
int thisvecR;

int contrecreo[]={755,800,840,920,930,935,1010,1050,1100,1140,1220,1300,1335,1340,1455,1500,1540};
//int contrecreo[]={1905,1908,1910,1912,1915,1930,1920,1935,1940,1945,1950,1955,2000,2005,2010,2015,2020};
int cnttiporecreo[]={
  1,3,1,1,2,3,1,1,3,1,1,1,2,2,1,2,1};
// 1  R corto - 2 R largo - 3  R L&Repet
int cntvec1=17;


void setup () {
  Wire.begin(); // Inicio el puerto I2C
  RTC.begin(); // Inicio la comunicación con el RTC
  //RTC.adjust(DateTime(2016,4,4,11,49,00)); // Establece la fecha y hora (Comentar una vez establecida la hora)
  Serial.begin(9600); // Establece la velocidad de datos del puerto serie
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("Timbre IPEA 238");
  pinMode(13, OUTPUT);
}

void loop(){
  ////*
  DateTime now = RTC.now(); // Obtiene la fecha y hora del RTC



  delay(1000); // La información se actualiza cada 1 seg.
  HORMIL=100*(now.hour())+ now.minute();

  seg=now.second();
  dia=now.dayOfWeek();
//  Serial.println();
// Serial.print(now.second(), DEC);
  // Esta rutina detecta la hora y acomoda el recreo
   if(thisvecR=0)
   {
   for (int thatvecR = 0; thatvecR < cntvec1; thatvecR++)
   {
   if(HORMIL==contrecreo[thatvecR])
   {
   thisvecR=thatvecR;
 
   }
   }
   }

  // Lee el vector secuencia horarios timbre
  if(dia>0 && dia<6){
    lcd.setCursor(0,1);
  lcd.print(now.day(), DEC); // Dia
  lcd.print('/');
  lcd.print(now.month(), DEC); // Mes
  lcd.print('/');
  lcd.print(now.year(), DEC); // Año
  lcd.print(' ');
  if (now.hour() < 10){
      lcd.print("0");
  }
  lcd.print(now.hour(), DEC); // Horas
  lcd.print(':');
  if (now.minute() < 10){
      lcd.print("0");
  }
  lcd.print(now.minute(), DEC); // Minutos
 
 //  COMPARO RELOJ CON EL VECTOR
  for (thisvecR = 0; thisvecR < cntvec1; thisvecR++)
  {
    if(HORMIL==contrecreo[thisvecR] && seg<10)
    {

      switch (cnttiporecreo[thisvecR])
      {
      case 1:
        Serial.println("Timbre Corto ");
        timbre_corto();

        break;
      case 2:
        Serial.println("Timbre Largo");
        timbre_largo();

        break;
      case 3:
        Serial.println("Timbre con Repeticion");
        timbre_corto();
        timbre_largo();

        break;
      }

      if(thisvecR == cntvec1)   // REPORTE SERIAL
      {
        thisvecR = 0;
      }
      Serial.print(now.year(), DEC); // Año
      Serial.print('/');
      Serial.print(now.month(), DEC); // Mes
      Serial.print('/');
      Serial.print(now.day(), DEC); // Dia
      Serial.print(' ');
      Serial.print(now.hour(), DEC); // Horas
      Serial.print(':');
      Serial.print(now.minute(), DEC); // Minutos
      Serial.print(':');
      Serial.print(now.second(), DEC); // Segundos
      Serial.print("  DS:");
      Serial.print(now.dayOfWeek(), DEC);
      Serial.print("  HM:");
      Serial.print(HORMIL);
      Serial.print(" contrecreo:");
      Serial.print(contrecreo[thisvecR]);
      Serial.print("  cntvec1:");
      Serial.print(thisvecR);
      Serial.println();
      Serial.print("-------------------------------------------------------------");
      Serial.println();
    }
  }    
   }
 else
 {
 lcd.setCursor(0,0);
 lcd.scrollDisplayLeft();
 lcd.print("DESCONECTADO F/S");
 lcd.setCursor(0,1);
 lcd.print("Olaf Tc:15406600");
 digitalWrite(13, LOW);
 delay(150);
 }
}
int timbre_corto()
{

  digitalWrite(13, HIGH);
  delay(2000);
  digitalWrite(13, LOW);
  delay(4000);

}
int timbre_largo()
{

  digitalWrite(13, HIGH);
  delay(4000);
  digitalWrite(13, LOW);
  delay(2000);

}
// funcion reporte serial a PC





Saludos para las pesonas que ven este blog

 Como mañana es mi cumpleaños 63 y quería compartirles con orgullo que pertenezco a esa clase de personas que tuvimos que actualizarnos ant...