Refactor MAX7219 initialization and update MQ7 reading delay
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
|
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
|
||||||
#define MAX_DEVICES 4 // 4 modulos 8x8
|
#define MAX_DEVICES 4 // 4 modulos 8x8
|
||||||
|
|
||||||
#define DATA_PIN 19
|
#define DATA_PIN 19
|
||||||
#define CS_PIN 18
|
#define CS_PIN 18
|
||||||
#define CLK_PIN 17
|
#define CLK_PIN 17
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ MD_Parola display = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVI
|
|||||||
void MAX7219_Init()
|
void MAX7219_Init()
|
||||||
{
|
{
|
||||||
display.begin();
|
display.begin();
|
||||||
display.setIntensity(1); // 0-15
|
display.setIntensity(15); // 0-15
|
||||||
display.displayClear();
|
display.displayClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ void MQ7_Init()
|
|||||||
|
|
||||||
void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue)
|
void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue)
|
||||||
{
|
{
|
||||||
|
// preheat
|
||||||
analogWrite(ANALOG_MQ7, 1023);
|
analogWrite(ANALOG_MQ7, 1023);
|
||||||
delay(60000);
|
delay(60000);
|
||||||
analogWrite(ANALOG_MQ7, (1023/5)*1.4 );
|
analogWrite(ANALOG_MQ7, (1023/5)*1.4 );
|
||||||
@@ -15,16 +16,11 @@ void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue)
|
|||||||
for(int i = 0; i<100; i++)
|
for(int i = 0; i<100; i++)
|
||||||
{
|
{
|
||||||
sensorValue = sensorValue + analogRead(ANALOG_MQ7);
|
sensorValue = sensorValue + analogRead(ANALOG_MQ7);
|
||||||
delay(90000);
|
delay(1200);
|
||||||
}
|
}
|
||||||
|
|
||||||
sensorValue = sensorValue/100.0;
|
sensorValue = sensorValue/100.0;
|
||||||
sensorVolt = sensorValue/1024*5.0;
|
sensorVolt = sensorValue/1024*5.0;
|
||||||
RSAir = (5.0-sensorVolt)/sensorVolt;
|
RSAir = (5.0-sensorVolt)/sensorVolt;
|
||||||
R0 = RSAir/(26+(1/3));
|
R0 = RSAir/(26+(1/3));
|
||||||
|
|
||||||
Serial.print("R0 = ");
|
|
||||||
Serial.println(R0);
|
|
||||||
|
|
||||||
delay(1000);
|
|
||||||
}
|
}
|
||||||
@@ -13,19 +13,19 @@ void setup()
|
|||||||
{
|
{
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
Serial.println("Iniciando...");
|
/*Serial.println("Iniciando...");
|
||||||
MQ7_Init();
|
MQ7_Init();
|
||||||
Serial.println("Sensor MQ7 inicializado");
|
Serial.println("Sensor MQ7 inicializado");
|
||||||
BME280_Init();
|
BME280_Init();
|
||||||
Serial.println("Sensor BME280 inicializado");
|
Serial.println("Sensor BME280 inicializado");
|
||||||
GPS_Init();
|
GPS_Init();
|
||||||
Serial.println("GPS inicializado");
|
Serial.println("GPS inicializado"); */
|
||||||
MAX7219_Init();
|
MAX7219_Init();
|
||||||
Serial.println("Display inicializado");
|
Serial.println("Display inicializado");
|
||||||
|
|
||||||
prettyReadBME280();
|
//prettyReadBME280();
|
||||||
prettyReadMQ7();
|
|
||||||
testMatrix();
|
testMatrix();
|
||||||
|
//prettyReadMQ7();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
@@ -65,6 +65,7 @@ void testMatrix()
|
|||||||
{
|
{
|
||||||
Serial.println("Escribiendo en el display...");
|
Serial.println("Escribiendo en el display...");
|
||||||
MAX7219_DisplayText("Prueba de texto", PA_LEFT, 100, 500);
|
MAX7219_DisplayText("Prueba de texto", PA_LEFT, 100, 500);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getChipID()
|
uint32_t getChipID()
|
||||||
|
|||||||
Reference in New Issue
Block a user