#include "DHT.h"
#include <MaxMatrix.h>
#include <avr/pgmspace.h>
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
#define DHTPIN 2 // DHT-11 out
#define DHTTYPE DHT11 // тип DHT-11
DHT dht(DHTPIN, DHTTYPE);
PROGMEM prog_uchar CH[] = {
3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space
1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // !
3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // "
5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // #
4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $
5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // %
5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // &
1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // '
3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // (
3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // )
5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // *
5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // +
2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // ,
4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // -
2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // .
4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // /
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0
3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1
4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2
4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3
4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4
4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5
4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6
4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7
4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8
4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9
2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // :
2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ;
3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // <
3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // =
3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // >
4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ?
5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @
4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A
4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B
4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C
5, 8, B01100000, B00111111, B00100001, B00111111, B01100000, // Д
4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E
4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F
4, 8, B01111111, B00000001, B00000001, B00000001, B00000000, // Г
4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H
5, 8, B01111111, B00010000, B00001000, B00000100, B01111111, // И
5, 8, B01100011, B00010100, B01111111, B00010100, B01100011, // Ж
4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K
4, 8, B01111110, B00000001, B00000001, B01111111, B00000000, // Л
5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M
5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O
4, 8, B01111111, B00000001, B00000001, B01111111, B00000000, // П
4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q
4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P
4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S
5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T
4, 8, B01000111, B01001000, B01001000, B00111111, B00000000, // У
4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B
5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W
5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X
5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y
4, 8, B01000110, B00101001, B00011001, B01111111, B00000000, // Я
2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [
4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash
2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ]
3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat
4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _
2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // `
4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a
4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b
4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c
4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d
4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e
3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f
4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g
4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h
3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i
4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j
4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k
3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l
5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m
4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n
4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o
4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p
4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q
4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r
4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s
3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t
4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u
5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v
5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w
5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x
4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y
3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z
3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // {
1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // |
3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // }
4, 8, B00000010, B00000101, B00000010, B00000000, B00000000, // ~ градус
};
int data = 8; // DIN pin of MAX7219 module
int load = 9; // CS pin of MAX7219 module
int clock = 10; // CLK pin of MAX7219 module
int maxInUse = 1; //change this variable to set how many MAX7219's you'll use (5)
MaxMatrix m(data, load, clock, maxInUse); // define module
byte buffer[10];
#include <IRremote.h>
IRsend irsend;
int y = 1;
void setup()
{
m.init(); // module initialize
m.setIntensity(10); // dot matix intensity 0-15
Serial.begin(9600); // serial communication initialize
Wire.begin(); // RTC_DS1307
RTC.begin();
// RTC.adjust(DateTime(__DATE__, __TIME__));
dht.begin(); // DHT-11
}
void matrix(){
int Temp = dht.readTemperature();
int Hum = dht.readHumidity();
DateTime now = RTC.now();
int TDay=now.day();
int TMonth=now.month();
int TYear=now.year();
int THour=now.hour();
int TMinutes=now.minute();
delay(100);
m.shiftLeft(false, true);
char string1[] = " Hello, my name is Vadim ... ";
sprintf(string1, "CEGODHZ %02d.%02d.%02d B %02d.%02d TEMPERATURA VO3DUXA %d~C VLAJHOCTb %i%% ", TDay, TMonth, TYear, THour, TMinutes, Temp, Hum);
Serial.println(string1);
printStringWithShift(string1, 100);
}
void printCharWithShift(char c, int shift_speed){
if (c < 32) return;
c -= 32;
memcpy_P(buffer, CH + 7*c, 7);
m.writeSprite(maxInUse*8, 0, buffer);
m.setColumn(maxInUse*8 + buffer[0], 0);
for (int i=0; i<buffer[0]+1; i++)
{
delay(shift_speed);
m.shiftLeft(false, false);
}
}
void printStringWithShift(char* s, int shift_speed){
while (*s != 0){
printCharWithShift(*s, shift_speed);
s++;
}
}
void printString(char* s)
{
int col = 0;
while (*s != 0)
{
if (*s < 32) continue;
char c = *s - 32;
memcpy_P(buffer, CH + 7*c, 7);
m.writeSprite(col, 0, buffer);
m.setColumn(col + buffer[0], 0);
col += buffer[0] + 1;
s++;
}
}
void loop() {
if (Serial.available() > 0) {
int x = Serial.read();
if (x == 49) {
y = 1;
}
if (x == 50) {
y = 2;
}
if (y == 1) { // коды кнопок для пульта от телевизора
if (x == 97) {
irsend.sendNEC(0x2FD48B7, 32);
delay(40);
}
if (x == 98) {
irsend.sendNEC(0x2FDDA25, 32);
delay(40);
}
if (x == 99) {
irsend.sendNEC(0x2FD708F, 32);
delay(40);
}
if (x == 100) {
irsend.sendNEC(0x2FDF00F, 32);
delay(40);
}
if (x == 101) {
irsend.sendNEC(0x2FDD02F, 32);
delay(40);
}
if (x == 102) {
irsend.sendNEC(0x2FD30CF, 32);
delay(40);
}
if (x == 103) {
irsend.sendNEC(0x2FDD827, 32);
delay(40);
}
if (x == 104) {
irsend.sendNEC(0x2FD38C7, 32);
delay(40);
}
if (x == 105) {
irsend.sendNEC(0x2FD7887, 32);
delay(40);
}
if (x == 106) {
irsend.sendNEC(0x2FDF807, 32);
delay(40);
}
if (x == 107) {
irsend.sendNEC(0x2FD28D7, 32);
delay(40);
}
if (x == 108) {
irsend.sendNEC(0x2FD50AF, 32);
delay(40);
}
if (x == 109) {
matrix; // !!! НА ЭТУ КНОПУ И ХОЧУ ПОВЕСИТЬ ВКЛЮЧЕНИЕ "БЕГУЩЕЙ СТРОКИ"
delay(40);
}
}
if (y == 2) { //коды кнопок пульта от медиаплеера
if (x == 97) {
irsend.sendNEC(0xFDC23D, 32);
delay(40);
}
if (x == 98) {
irsend.sendNEC(0xFDE01F, 32);
delay(40);
}
if (x == 99) {
irsend.sendNEC(0xFD18E7, 32);
delay(40);
}
if (x == 100) {
irsend.sendNEC(0xFDE817, 32);
delay(40);
}
if (x == 101) {
irsend.sendNEC(0xFDA857, 32);
delay(40);
}
if (x == 102) {
irsend.sendNEC(0xFD6897, 32);
delay(40);
}
if (x == 103) {
irsend.sendNEC(0xFDA857, 32);
delay(40);
}
if (x == 104) {
irsend.sendNEC(0xFD6897, 32);
delay(40);
}
if (x == 105) {
irsend.sendNEC(0xFDE817, 32);
delay(40);
}
if (x == 106) {
irsend.sendNEC(0xFD18E7, 32);
delay(40);
}
if (x == 107) {
irsend.sendNEC(0xFD9867, 32);
delay(40);
}
if (x == 108) {
irsend.sendNEC(0xFD28D7, 32);
delay(40);
}
if (x == 109) {
irsend.sendNEC(0xFD2847, 32);
delay(40);
}
}
}
}