Air Quality Sensor Measurement RGB Matrix Output [P004]
https://www.youtube.com/watch?v=BxdZ1Tk4Mmw
https://www.youtube.com/watch?v=yhVOXsE28B4
https://www.youtube.com/watch?v=vl9jQZMoH-o
*GitHub : https://github.com/rdiot/rdiot-p004.git
* Parts
- Arduino Mega
- Air Quality Sensor (MQ135) [S037]
- 32x64 RGB LED Matrix P4 (LM-P4-SMD-RGB-LED) [D025]
- SI7021 Humidity Sensor (GY-21) [S068]
- Photo Resistor Module (KY-018) [S002]
* Contents
- Key Code
#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#include <MQ135.h>
#include <Wire.h>
int pin = A5; // Air Quality Sensor
// LED Matrix
#define OE 9
#define LAT 10
#define CLK 11
#define A A0
#define B A1
#define C A2
#define D A3
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false, 64);
MQ135 gasSensor = MQ135(pin);
#define RZERO 76.63
double rzero;
double result;
int i=0;
double rzero;
double result;
void setup() {
matrix.begin(); // LED Matrix init
matrix.drawPixel(0, 0, matrix.Color333(7, 7, 7));
delay(500);
matrix.fillRect(0, 0, 64, 32, matrix.Color333(0, 7, 0));
delay(3000);
}
void loop() {
matrix.fillScreen(matrix.Color333(0, 0, 0));
matrix.setCursor(1, 1); // start at top left, with 8 pixel of spacin
if (i==0) {
rzero = gasSensor.getRZero(); // float
}
if (i>0) {
result = gasSensor.getRZero();
rzero = (rzero + result)/2;
}
float co2_ppm = gasSensor.getPPM();
matrix.println("rz:"+(String)rzero+" ");
matrix.setCursor(1, 9); // start at top left, with 8 pixel of spacing
matrix.println("rs:"+(String)result+" ");
matrix.setCursor(1, 16); // start at top left, with 8 pixel of spacing
matrix.println("D:"+(String)analogRead(pin)+" ");
matrix.setCursor(1, 23); // start at top left, with 8 pixel of spacing
matrix.println("A:"+(String)co2_ppm+"ppm");
i++;
if(co2_ppm > 10)
{
matrix.drawRect(0, 0, 64, 32, matrix.Color333(0, 4, 7));
}
else
{
// matrix.drawRect(0, 0, 64, 32, matrix.Color333(0, 4, 7));
}
//cool down
delay(1000);
}
'3) Actuator > LED_Matrix' 카테고리의 다른 글
NeoPixel Stick - 8 x WS2812 (5050RGB) [D009] (0) | 2016.09.21 |
---|---|
WS2812 16x5050 RGB LED Ring Lamp Light (SMD5050) [D065] (0) | 2016.09.21 |
32x64 RGB LED Matrix P4 (LM-P4-SMD-RGB-LED) Basic Test [D025] (0) | 2016.09.12 |