bagaimana cara menggabung codingan led matrix dan codingan sensor suara(KY-037)
dengan sistem kerja:
jika nilai sensor > 25 akan menyala lampu hijau & tampil “ SEDANG SIDANG”
jika nilai sensor > 83 akan menyala lampu kuning & tampil “ TOLONG PELANKAN SUARA”
jika nilai sensor > 120 akan menyala lampu merah & tampil “ JANGAN RIBUT”
0 Thanks |
Share |
Admin
Verified
10 months ago |
bisa coba dilampirkan kodingnya secara menyeluruh kak
utari rahmatillah
10 months ago |
// Including the required Arduino libraries
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Uncomment according to your hardware type
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
//#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW
// Defining size, and output pins
#define MAX_DEVICES 4
#define CS_PIN 3
#define CLK_PIN 13
#define DATA_PIN 11
// Create a new instance of the MD_Parola class with hardware SPI connection
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
int sensor = A0;
int LEDgreen = 7;
int LEDyellow = 6;
int LEDred = 5;
int nilaiSensor;
void setup() {
// Intialize the object
myDisplay.begin();
// Set the intensity (brightness) of the display (0-15)
myDisplay.setIntensity(0);
// Clear the display
myDisplay.displayClear();
Serial.begin(9600);
pinMode(sensor, INPUT);
pinMode(LEDgreen, OUTPUT);
pinMode(LEDyellow, OUTPUT);
pinMode(LEDred, OUTPUT);
// put your setup code here, to run once:
}
void loop() {
int nilaiSensor = analogRead(sensor);
Serial.print("sensor = ");
Serial.println(nilaiSensor);
if(nilaiSensor > 25){
digitalWrite(LEDgreen, HIGH);
Serial.print("sensor = ");
Serial.print(nilaiSensor);
Serial.print("sensitivity low");
myDisplay.setTextAlignment(PA_LEFT);
myDisplay.print("SIDANG");}
delay(2000);
if(nilaiSensor > 63){
digitalWrite(LEDyellow, HIGH);
Serial.print("sensor = ");
Serial.print(nilaiSensor);
Serial.print("sensitivity medium");}
myDisplay.setTextAlignment(PA_CENTER);
myDisplay.print("TOLONG PELANKAN SUARA");}
if(nilaiSensor > 90){
digitalWrite(LEDred, HIGH);
Serial.print("sensor = ");
Serial.print(nilaiSensor);
Serial.print("sensitivity high");
myDisplay.setTextAlignment(PA_CENTER);
myDisplay.print("JANGAN RIBUT");}
else{
digitalWrite(LEDgreen, LOW);
digitalWrite(LEDyellow, LOW);
digitalWrite(LEDred, LOW);}
delay(2);
}
Gunakanlah Kata kata yang sopan