week11

parent 3460e93b
Pipeline #82225 passed with stage
in 29 seconds
#include <SoftwareSerial.h>
SoftwareSerial monserial(0, 1);
long distancia;
long tiempo;
int trigger=10;
int echo=9;
void setup() {
// put your setup code here, to run once:
monserial.begin(9600);
pinMode(trigger, OUTPUT);
pinMode(echo, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trigger,LOW);
delayMicroseconds(5);
digitalWrite(trigger,HIGH);
delayMicroseconds(10);
tiempo=pulseIn(echo,HIGH);
distancia= int(0.0175*tiempo);
monserial.println("Distance ");
monserial.println(distancia);
monserial.println(" cm");
delay(500);
}
#include <SoftwareSerial.h>
SoftwareSerial monserial(0, 1);
long distancia;
long tiempo;
int trigger=10;
int echo=9;
int ther=A2;
float temp;
float value;
float reading;
void setup() {
// put your setup code here, to run once:
pinMode(ther,INPUT);
pinMode(trigger, OUTPUT);
pinMode(echo, INPUT);
monserial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trigger,LOW);
delayMicroseconds(5);
digitalWrite(trigger,HIGH);
delayMicroseconds(10);
tiempo=pulseIn(echo,HIGH);
distancia= int(0.0175*tiempo);
value=analogRead(ther);
reading = (1023.0 / value) - 2.0;)
temp = reading*100.0;
monserial.print(distancia);
monserial.println(temp);
}
#include <SoftwareSerial.h>
SoftwareSerial monserial(0, 1);
int ther=A2;
float temp;
float value;
float reading;
void setup() {
pinMode(ther,INPUT);
monserial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
value=analogRead(ther);
reading = (1023.0 / value) - 2.0;
temp = reading*100.0;
monserial.print("Temperature ");
monserial.println(temp);
delay(1000);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment