Χωρίς κατηγορία
Απλό ψηφιακό ρολόι με wemos και oled οθόνη.
Υλικά:
1 wemos d1 r1 mini (lolin)
1 OLED Display ssd1306 128×64 I2C
1 παλιό φορτιστή κινητού
Καλώδια και ένα κουτάκι για σασί.
Αρχείο για εκτύπωση κουτιού σε 3d printer. box
Πρόγραμμα για το wemos
// Libraries needed:
// Time.h & TimeLib.h: https://github.com/PaulStoffregen/Time
// Timezone.h: https://github.com/JChristensen/Timezone
// SSD1306.h & SSD1306Wire.h: https://github.com/squix78/esp8266-oled-ssd1306
// NTPClient.h: https://github.com/arduino-libraries/NTPClient
// ESP8266WiFi.h & WifiUDP.h: https://github.com/ekstrand/ESP8266wifi
//
#include <ESP8266WiFi.h>
#include <WifiUDP.h>
#include <String.h>
#include <Wire.h>
//#include <SSD1306.h>
//#include <SSD1306Wire.h>
#include <NTPClient.h>
#include <Time.h>
#include <TimeLib.h>
#include <Timezone.h>
#include <TM1637Display.h>
const int CLK = D6; //Set the CLK pin connection to the display
const int DIO = D5; //Set the DIO pin connection to the display
TM1637Display display(CLK, DIO); //set up the 4-Digit Display.
// Define NTP properties
#define NTP_OFFSET 60 * 60 // In seconds
#define NTP_INTERVAL 60 * 1000 // In miliseconds
#define NTP_ADDRESS “ca.pool.ntp.org” // change this to whatever pool is closest (see ntp.org)
// Set up the NTP UDP client
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, NTP_ADDRESS, NTP_OFFSET, NTP_INTERVAL);
const char* ssid = “********”; // insert your own ssid
const char* password = “********”; // and password
String date;
String t;
const char * days[] = {“Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”} ;
const char * months[] = {“Jan”, “Feb”, “Mar”, “Apr”, “May”, “June”, “July”, “Aug”, “Sep”, “Oct”, “Nov”, “Dec”} ;
const char * ampm[] = {“AM”, “PM”} ;
int k = 0;
int timer=0;
void setup ()
{
Serial.begin(115200); // most ESP-01’s use 115200 but this could vary
timeClient.begin(); // Start the NTP UDP client
// Connect to wifi
Serial.println(“”);
Serial.print(“Connecting to “);
Serial.print(ssid);
//display.drawString(0, 10, “Connecting to Wifi…”);
// display.display();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(“.”);
}
Serial.println(“”);
Serial.print(“Connected to WiFi at “);
Serial.print(WiFi.localIP());
Serial.println(“”);
// display.drawString(0, 24, “Connected.”);
// display.display();
display.setBrightness(0x0f); //set the diplay to maximum brightness
delay(1000);
}
void loop()
{
if(k==0){
if (WiFi.status() == WL_CONNECTED) //Check WiFi connection status
{
date = “”; // clear the variables
t = “”;
// update the NTP client and get the UNIX UTC timestamp
timeClient.update();
unsigned long epochTime = timeClient.getEpochTime();
// convert received time stamp to time_t object
time_t local, utc;
utc = epochTime;
// Then convert the UTC UNIX timestamp to local time
TimeChangeRule usEDT = {“EDT”, Second, Sun, Mar, 2, +120}; //UTC + 2 hours – change this as needed
TimeChangeRule usEST = {“EST”, First, Sun, Nov, 2, +60}; //UTC + 1 hours – change this as needed
Timezone usEastern(usEDT, usEST);
local = usEastern.toLocal(utc);
// now format the Time variables into strings with proper names for month, day etc
date += days[weekday(local)-1];
date += “, “;
date += months[month(local)-1];
date += ” “;
date += day(local);
date += “, “;
date += year(local);
// format the time to 12-hour format with AM/PM and no seconds
t += hourFormat12(local);
t += “:”;
if(minute(local) < 10) // add a zero if minute is under 10
t += “0”;
t += minute(local);
t += ” “;
t += ampm[isPM(local)];
int HH=hourFormat12(local)*100; //display on $digit 7segment
int MM=minute(local);
timer=HH+MM;
// Display the date and time
Serial.println(“”);
Serial.print(“Local date: “);
Serial.print(date);
Serial.println(“”);
Serial.print(“Local time: “);
Serial.print(t);
}
else // attempt to connect to wifi again if disconnected
{
WiFi.begin(ssid, password);
delay(1000);
}
}
k++;
if(k==9)k=0;
// Print 1234 with the center colon:
display.showNumberDecEx(timer, 0b11100000, false, 4, 0);
delay(500);
display.showNumberDecEx(timer);
delay(500);
delay(10); //Send a request to update every 10 sec (= 10,000 ms)
}
Σχολικό κουδούνι ελεγχόμενο από micro-controller.
Η υλοποίηση πραγματοποιήθηκε με τη χρήση Arduino nano v3.0
Λίστα Υλικών:
arduino nano ή οτιδήποτε arduino διαθέτετε
lcd 2×16
relay 5v (έτοιμο κυκλωματάκι με transistor , δίοδο κλπ)
led
αντιστάσεις 1Κ
RTC DS1302 ρολόι
δύο διακοπτάκια , ποτενσιόμετρο 10K
διάτρητη πλακέτα, καλώδια, τροφοδοτικό 5v (από παλιό κινητό είναι τέλειο) , πλαστικό κουτάκι
και φυσικά όρεξη για κατασκευές.
Σχηματικό διάγραμμα
Κώδικας για το 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————————————————————————————-
Η θερμική μηχανή εξωτερικής καύσης Stirling.
Κατασκευή μηχανής Stirling.
Hello world!
Καλωσήρθατε στο Blogs.sch.gr. Αυτή είναι η πρώτη σας δημοσίευση. Αλλάξτε την ή διαγράψτε την και αρχίστε το “Ιστολογείν”!
Συμβουλευτείτε τα αρχεία βοήθειας για την διαχείριση του ιστολογίου σας.
This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.
Πρόσφατα σχόλια