grimanis's blog

Just another Blogs.sch.gr site

Σχολικό κουδούνι ελεγχόμενο από micro-controller.

Σεπ 201421

 

Η υλοποίηση πραγματοποιήθηκε με τη χρήση Arduino nano v3.0

Λίστα Υλικών:

arduino nano ή οτιδήποτε arduino διαθέτετε

lcd 2×16

relay 5v (έτοιμο κυκλωματάκι με transistor , δίοδο κλπ)

led

αντιστάσεις 1Κ

RTC DS1302 ρολόι

δύο διακοπτάκια , ποτενσιόμετρο 10K

διάτρητη πλακέτα, καλώδια, τροφοδοτικό 5v (από παλιό κινητό είναι τέλειο) , πλαστικό κουτάκι

και φυσικά όρεξη για κατασκευές.

 

school_bell_bbυλοποίηση

Σχηματικό διάγραμμα

Κώδικας για το arduino:

copy ————————————————————————————————

/*##########################################################
      Title:       Control School Bell
      Purpose:     Rings a bell at programmed  
      Created by:  griman,   Sep 2014
      Note:        Please reuse, repurpose, and redistribute this code.
*/

#include <virtuabotixRTC.h>
#include <LiquidCrystal.h>    

//  RTC Pinout     SCLK -> pin6, I/O -> pin7, CE -> pin8
virtuabotixRTC myRTC(6, 7, 8);

/*  The circuit:LCD Pinout
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K pot:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3) */

// include the library code:
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int bell=9;
long time;
int sec;
int trigger=0;
int hours;
int minutes;
int secs;
int m1;    //display decates mins
int m2;    //displays mins
int s1;    //displays decates secs
int s2;

void setup()
{

Serial.begin(9600);

  lcd.begin(16, 2);  // set up the LCD’s number of columns and rows:
  pinMode (bell,OUTPUT);
  digitalWrite(bell,HIGH);    //set to HIGH becouse relay is active LOW

// Set the current date, and time in the following format:
// seconds, minutes, hours, day of the week, day of the month, month, year

//myRTC.setDS1302Time(30, 15, 17, 6, 20, 9, 2014); //when set once please disable
}

void loop()
{

// This allows for the update of variables for time or accessing the individual elements.

myRTC.updateTime();
time = myRTC.hours*10000L+myRTC.minutes*100L+myRTC.seconds;
//ελεγχος για το αν θα χτυπησει κουδουνι
  if(time==81500)drinIn();    //αρχη 1η WRA
  if(time==90000)drinOut();
  if(time==90500)drinIn();    //2η WRA
  if(time==95000)drinOut();  
  if(time==100000)drinIn();    //3η WRA
  if(time==104500)drinOut();  
  if(time==105500)drinIn();   //4η WRA
  if(time==113500)drinOut();  
  if(time==114500)drinIn();    //5η WRA
  if(time==122500)drinOut();  
  if(time==123500)drinIn();    //6η WRA
  if(time==131500)drinOut();
  if(time==132000)drinIn();    //7η WRA
  if(time==135500)drinOut();     //τελος
 
  //count  hours 1,2,….
     if(time>=81500 and time<=90000){
       lcd.clear();   
       lcd.setCursor(0, 1);
       lcd.print(“WRA 1”);}
     if(time>90000 and time<90500){
      lcd.clear();
      lcd.setCursor(0, 1);  
      lcd.print(“DIALEIMMA 1”);}
     if(time>=90500 and time<=95000){
       lcd.clear();   
       lcd.setCursor(0, 1);
       lcd.print(“WRA 2”);}
     if(time>95000 and time<100000){
       lcd.clear();
       lcd.setCursor(0, 1);  
       lcd.print(“DIALEIMMA 2”);}
     if(time>=100000 and time<=104500){
       lcd.clear();   
       lcd.setCursor(0, 1);
       lcd.print(“WRA 3”);}
     if(time>104500 and time<105500){
       lcd.clear();  
       lcd.setCursor(0, 1);
       lcd.print(“DIALEIMMA 3”);}
     if(time>=105500 and time<=113500){
       lcd.clear();   
       lcd.setCursor(0, 1);
       lcd.print(“WRA 4”);}
     if(time>113500 and time<114500){
        lcd.clear();  
        lcd.setCursor(0, 1);
        lcd.print(“DIALEIMMA 4”);}
     if(time>=114500 and time<=122500){
       lcd.clear();   
       lcd.setCursor(0, 1);
       lcd.print(“WRA 5”);}
     if(time>122500 and time<123500){
        lcd.clear();  
        lcd.setCursor(0, 1);
        lcd.print(“DIALEIMMA 5”);}
     if(time>=123500 and time<=131500){
       lcd.clear();   
       lcd.setCursor(0, 1);
       lcd.print(“WRA 6”);}
     if(time>131500 and time<132000){
        lcd.clear();  
        lcd.setCursor(0, 1);
        lcd.print(“DIALEIMMA 6”);}
     if(time>=132000 and time<=135500){
       lcd.clear();   
       lcd.setCursor(0, 1);
       lcd.print(“WRA 7”);}
     if(time>135500){
        lcd.clear();  
        lcd.setCursor(0, 1);
        lcd.print(“FIN”);}
     if(time<81500){
       lcd.clear();  
       lcd.setCursor(0, 1);
       lcd.print(“START UR ENGINES”);}

   hours=time/10000L;
   minutes=(time-10000L*hours)/100L;
   secs=time-10000*hours-100*minutes;
 
    m1=minutes/10;
    m2=minutes-m1*10;
    s1=secs/10;
    s2=secs-s1*10;
 
 //display time on LCD
lcd.setCursor(0, 0);
lcd.print(“Time = “);
lcd.print(hours);
lcd.print(“:”);
lcd.print(m1);
lcd.print(m2);
lcd.print(“:”);
lcd.print(s1);
lcd.print(s2);

// Start printing elements as individuals just for debug
Serial.print(“day of the week : “);
Serial.print(myRTC.dayofweek);
Serial.print(” Time:”);
Serial.print(time);
Serial.print(“Current Date / Time: “);
Serial.print(myRTC.dayofmonth);
Serial.print(“/”);
Serial.print(myRTC.month);
Serial.print(“/”);
Serial.print(myRTC.year);
Serial.print(” “);
Serial.print(myRTC.hours);
Serial.print(“:”);
Serial.print(myRTC.minutes);
Serial.print(“:”);
Serial.println(myRTC.seconds);

// Delay so the program doesn’t print non-stop

delay( 100);
}

void drinIn()  
{
      if(myRTC.dayofweek<=5){    //disable use at Saturday and Sunday ,  1=Monday….5=Friday
      digitalWrite(bell,LOW);
      delay(5000);
      digitalWrite(bell,HIGH);
}
}

void drinOut()  
{
      if(myRTC.dayofweek<=5){    //disable use at Saturday and Sunday ,  1=Monday….5=Friday
      digitalWrite(bell,LOW);
      delay(3000);
      digitalWrite(bell,HIGH);
}
}

copy————————————————————————————-

 

 

 

 2014-09-20 18.19.44-1   έτοιμο…

Αφήστε μια απάντηση

Η ηλ. διεύθυνση σας δεν δημοσιεύεται. Τα υποχρεωτικά πεδία σημειώνονται με *



Αλλαγή μεγέθους γραμματοσειράς
Αντίθεση
Μετάβαση σε γραμμή εργαλείων