kodenya seperti ini disini ane pake lcd menngunakan i2c dan sensor sht11
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SHT1x.h>
#define dataPin 10
#define clockPin 11
LiquidCrystal_I2C lcd(0x27, 16, 2);
SHT1x sht1x(dataPin, clockPin);
float temp_c;
float humidity;
float temp_f;
int screenWidth = 16;
int screenHeight = 2;
// ini text untuk scrolling
String line1 = "Ini scrolling text bro";
int stringStart, stringStop = 0;
int scrollCursor = screenWidth;
void setup() {
lcd.begin();
Serial.begin(9600);
}
void loop() {
temp_c = sht1x.readTemperatureC();
humidity = sht1x.readHumidity();
temp_f = sht1x.readTemperatureF();
lcd.setCursor(0,0);
lcd.print("T: C H: %");
lcd.setCursor(2,0);
lcd.print(temp_c,1);
lcd.setCursor(11,0);
lcd.print(humidity,1);
delay(100);
lcd.setCursor(scrollCursor, 1);
lcd.print(line1.substring(stringStart,stringStop));
delay(50);
lcd.print(" ");
//lcd.clear();
if(stringStart == 0 && scrollCursor > 0){
scrollCursor--;
stringStop++;
} else if (stringStart == stringStop){
stringStart = stringStop = 0;
scrollCursor = screenWidth;
} else if (stringStop == line1.length() && scrollCursor == 0) {
stringStart++;
} else {
stringStart++;
stringStop++;
}
}
bro minta penjelasan kodingnya secara lengkap dong, trims
BalasHapusPerbaris gitu?;)
Hapus