I don't know what's wrong with my code or my wiring. I need to get output from my LDR and LM35 sensor. This is my code :
int sensorReading, led, tempPin=1;//analog pin reading
float temp;
void setup()
{
Serial.begin(9600);
pinMode(6,OUTPUT);
}
void loop()
{
bacaLDR();
bacaTemp();
}
void bacaTemp(){
temp = analogRead(tempPin);
temp = temp * 0.48828125;
Serial.print("Temperatur : ");
Serial.print(temp);
Serial.println("*C");
delay(500);
}
void bacaLDR(){
sensorReading=analogRead(0); //get analog reading
led=map(sensorReading, 0, 1023, 255, 0);
analogWrite(6, led);
Serial.print("Sensor : ");
Serial.println(sensorReading);
Serial.print("LED : ");
Serial.println(led);
delay(500);
}
When i join both of them, the output of LM35 was random, but when i deleted code of reading LDR sensor LM35 give the right output. Can anyone help me?