несколько диспеев на max7219

dimin21590
dimin21590 аватар
Offline
Зарегистрирован: 26.10.2016

Есть у меня два дисплея на MAX7219 на первий вся вивести получается а вот второй молчит.

Вот код там много ненужного и недоработаного ма только нада узнать как вивести свое значения на 1й 2й и так дальше дисплеи.

#include "DHT.h"
#include "LedControlMS.h"
#include <DS1307.h>
#define DHTPIN 2     
#define DHTTYPE DHT22 
DHT dht(DHTPIN, DHTTYPE);

int set_button ;
int set_button_t ;
int set_button_pin = 7;
int set_button_pin_t = 6;
int newhour ;
int newminute ;
int hundreds = 0;
int tens = 0;
int ones = 0;
int hundredsH = 0;
int tensH = 0;
int onesH = 0;
int T1 = 0;
int H1 = 0;
char mm = ' ';
int cof = 0;
DS1307 rtc(4, 5);\
// I assume you know how to connect the DS1307.
// DS1307:  SDA pin   -> Arduino Digital 4
//          SCL pin   -> Arduino Digital 5
/*
 ***** These pin numbers will probably not work with your hardware *****
 pin 12 is connected to the DataIn 
 pin 11 is connected to the CLK 
 pin 10 is connected to LOAD 
 We have only a single MAX72XX.
 */
 // I assume you know how to connect the DS1307.
// DS1307:  SDA pin   -> Arduino Digital 4
//          SCL pin   -> Arduino Digital 5
LedControl lc=LedControl(12,11,10,2);
unsigned long delaytime=250;
void setup() 
{
  rtc.halt(false);
  
  pinMode(set_button_pin, INPUT);
  pinMode(set_button_pin_t, INPUT);

    
    lc.shutdown(0,false);
  lc.shutdown(1,false);
    lc.setIntensity(0,8);
    lc.shutdown(1,false);
   Serial.begin(9600);
  
 
  pinMode(2, INPUT);
  digitalWrite(2, HIGH);
  pinMode(3, INPUT);
  digitalWrite(3, HIGH);
  dht.begin();
}
void writeOn7Segment() {
  lc.setChar(0,0,ones,false); 
  lc.setChar(0,1,tens,true);
  lc.setChar(0,2,hundreds,false);
  lc.setChar(0,3,mm,false);
  lc.setChar(0,4,onesH,false); 
  lc.setChar(0,5,tensH,true); 
  lc.setChar(0,6,hundredsH,false);
  lc.setChar(0,7,' ',false);  

}
void timing(){
  set_button = digitalRead(set_button_pin);
  if(set_button==1){
    
    newhour++ ;
    if(newhour > 24){
      newhour = newhour-25;
    }
   rtc.setTime(newhour, newminute, 0);
  delay (300);  
  }
  set_button_t = digitalRead(set_button_pin_t);
  if(set_button_t==1){
    
    newminute++ ;
    if(newminute > 60){
      newminute = newminute-61;
    }
   rtc.setTime(newhour, newminute, 0);
  delay (300); 
  }
  
    
  
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");
  
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");


  
  Serial.println(rtc.getTimeStr());
  Serial.println(set_button);

  delay (10);
  
  }
void loop() {
 
  timing();
  writeOn7Segment();
  float H = dht.readHumidity();
  float T = dht.readTemperature();
  float hic = dht.computeHeatIndex(T, H, false);
  int i = 0;
if(H>95){
 H = H + 1.1;
}
if(T<0){
    mm = '-';
    T = T*-1;
    cof = 1;
}else{
    mm = ' ' ;
    cof = 0;
  }
  T1 =T*10; 
hundreds = T1/100;
            
tens=(T1-hundreds*100)/10;
    
ones=T1-(hundreds*100+tens*10);
H1 = H*10;
     
hundredsH = H1/100;
            
tensH=(H1-hundredsH*100)/10;
    
onesH=H1-(hundredsH*100+tensH*10);


}

 

Штирлиц
Штирлиц аватар
Offline
Зарегистрирован: 13.06.2015

Нужно сначала инициализировать  второй (и третий , и т.д) дисплеи в сетапе

void setup() {
 
  lc.shutdown(0,false);
  lc.setScanLimit(0,3);//количество включеных цыфр
  lc.setIntensity(0,12);//яркость
  lc.clearDisplay(0);
  
    lc.shutdown(1,false);
  lc.setIntensity(1,12);
  lc.clearDisplay(1);
  
    lc.shutdown(2,false);
  lc.setIntensity(2,12);
  lc.clearDisplay(2);
}

А потом и в скетче   выводить на первый -то , на второй - другое

 первый
 lc.setDigit(0,0,1,false);//
  lc.setDigit(0,1,2,true);//точки зажжены
  lc.setDigit(0,2,3,true);//точки зажжены
  lc.setDigit(0,3,0,false);//
второй
 lc.setDigit(1,0,1,false);//температура
  lc.setDigit(1,1,3,false);//температура
  lc.setDigit(1,2,4,true);//температура
  lc.setDigit(1,3,0,false);//температура
  lc.setDigit(1,4,2,true);//давление
  lc.setDigit(1,5,1,false);//давление
  lc.setDigit(1,6,0,false);//давление

 

dimin21590
dimin21590 аватар
Offline
Зарегистрирован: 26.10.2016

спасибо работает :)