Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // A sample of code of how to use the lib
- // The Lib
- #include <LM35.h>
- //Set the sensor
- // Configuration: LM35 variable(pin);
- LM35 temp(A0);
- float temperatura = 0;
- void setup()
- {
- //Set the pin mode
- pinMode(A0, INPUT);
- pinMode(10, OUTPUT);
- pinMode(11, OUTPUT);
- pinMode(12, OUTPUT);
- }
- void loop()
- {
- if(temperatura < 10){
- digitalWrite(10, HIGH);
- digitalWrite(11, LOW);
- digitalWrite(12, LOW);
- }
- if((temperatura >= 10) && (temperatura < 35)){
- digitalWrite(10, LOW);
- digitalWrite(11, HIGH);
- digitalWrite(12, LOW);
- }
- if((temperatura >= 35)){
- digitalWrite(10, LOW);
- digitalWrite(11, LOW);
- digitalWrite(12, HIGH);
- }
- temperatura = temp.cel(); // Converts the data to Celsius and sends to serial
- delay(250); // Delay to watch better the results
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement