I'm trying to Read values from LM35 sensor on Arduino UNO and send it to another Arduino board through a PWM pin and an analog Pin
When I run this project, The Serial Emulator of Arduino A is showing right values but Second one is always 0.00. Here is my first Arduino Code:
int pin = 2;
int TempPin = A0;
int pinAnalog = 3;
void setup() {
pinMode(3, OUTPUT);
Serial.begin(9600);
}
void loop() {
float tmp = analogRead(TempPin);
float Result = (tmp/1024.0) * 500;
Serial.println(Result);
analogWrite(pinAnalog, Result);
delay(3000);
}
And Here is My Second Arduino Code:
void setup() {
Serial.begin(9600);
}
void loop() {
float res = analogRead(A0);
Serial.println(res);
delay(3000);
}
What's wrong with my project or code?
float
is the wrong datatype: analogWrite takes a byte ( 0 .. 255 ) as value. analogRead returns an int. – datafiddler