Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double D = 0.43;
- byte sensor = 2;
- byte sensor2 = 3;
- volatile unsigned long tiempo = 0;
- volatile unsigned long tiempo2 = 0;
- volatile unsigned long resultado = 0;
- volatile double r = 0;
- volatile double result = 0;
- volatile double v = 0;
- void setup() {
- Serial.begin(9600);
- Serial.println("Iniciando Arduino");
- attachInterrupt(digitalPinToInterrupt(sensor),T1,HIGH);
- attachInterrupt(digitalPinToInterrupt(sensor2),T2,HIGH);
- }
- void loop() {
- }
- void T1(){
- tiempo = millis();
- //Serial.print("Tiempo: ");
- //Serial.println(tiempo);
- }
- void T2(){
- tiempo2 = millis();
- //Serial.print("Tiempo2: ");
- //Serial.println(tiempo2);
- resultado = tiempo2-tiempo;
- result = resultado;
- r = (result/1000);
- v=D/r;
- if((resultado >0) and (resultado<1000)){
- /* Serial.print("resultado: ");
- /Serial.print(resultado);
- Serial.print("-");
- Serial.print((result)/1000);
- */Serial.print("t: ");
- Serial.println(r);
- Serial.print("v: ");
- Serial.print(v);
- Serial.print("m/s");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement