Created
June 13, 2018 04:26
-
-
Save lol97/fc5a46511b13d829a0cd445682672e67 to your computer and use it in GitHub Desktop.
Source code untuk monitoring 3 sensor kelembaban tanah
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Sufyan Saori | |
xsufyan@gmail.com | |
Log Data Moisture Sensor V.0.001*/ | |
#include <TimeLib.h> | |
#define PIN1 A0 | |
#define PIN2 A1 | |
#define PIN3 A2 | |
#define PIN4 A3 | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(115200); | |
pinMode(PIN1, INPUT); | |
pinMode(PIN2, INPUT); | |
pinMode(PIN3, INPUT); | |
pinMode(PIN4, INPUT); | |
} | |
int waktu = 0; | |
void loop() { | |
// put your main code here, to run repeatedly: | |
int nilai1 = analogRead(PIN1); | |
int nilai2 = analogRead(PIN2); | |
int nilai3 = analogRead(PIN3); | |
int nilai4 = analogRead(PIN4); | |
setTime(waktu); | |
cetakWaktu(nilai1, nilai2, nilai3, nilai4); | |
delay(1000); | |
waktu += 1; | |
} | |
void cetakWaktu(int nilai1, int nilai2, int nilai3, int nilai4) { | |
Serial.print(hour()); | |
printDigits(minute()); | |
printDigits(second()); | |
Serial.print(" "); | |
Serial.print(nilai1); | |
Serial.print(" "); | |
Serial.print(nilai2); | |
Serial.print(" "); | |
Serial.print(nilai3); | |
Serial.print(" "); | |
Serial.print(nilai4); | |
Serial.println(); | |
} | |
void printDigits(int digits) { | |
Serial.print(":"); | |
if (digits < 10) { | |
Serial.print('0'); | |
} | |
Serial.print(digits); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment