Hi,
I have an Attiny85, a 0.96" 128X64 White OLED LED Display Module IIC I2C and a Light Sensor Module LDR. The code works okay but the issue is that the sensor value (sensorValue) continuously flickers, the rest of the code appears to be okay.
The code as follows:
#include <Tiny4kOLED.h>
#include <TinyWireM.h>
int sensorPin = 3; // select the input pin for LDR
int sensorValue = 0;
String LightStatus = "LED = ";
// OLED display TWI address
#define OLED_ADDR 0x3C
static char LLS[5];
void setup()
{
pinMode(4, OUTPUT);
oled.begin();
oled.clear();
oled.on();
oled.switchRenderFrame();
}
void loop()
{
sensorValue = analogRead(sensorPin);
oled.setCursor(12, 5);
oled.setFont(FONT6X8);
oled.print((String)"LL = " + sensorValue );
if (sensorValue > 500)
{
oled.clear();
digitalWrite(4,HIGH);
oled.setFont(FONT6X8);
oled.setCursor(12, 0);
oled.print(LightStatus + " ON");
//oled.switchFrame();
}
else
{
oled.clear();
digitalWrite(4,LOW);
oled.setFont(FONT6X8);
oled.setCursor(12, 0);
oled.print(LightStatus + " OFF");
//oled.switchFrame();
}
oled.switchFrame();
//delay(1000);
}