Diferencia entre revisiones de «Sensor de proximidad infrarrojo»

Sin resumen de edición
Sin resumen de edición
Línea 200: Línea 200:


<syntaxhighlight lang="c++" line copy>
<syntaxhighlight lang="c++" line copy>
/***************************************************
DFPlayer - A Mini MP3 Player For Arduino
  <https://www.dfrobot.com/product-1121.html>
  <https://www.dfrobot.com/product-1121.html>
   
   
Línea 263: Línea 265:
    
    
   myDFPlayer.volume(20);  //Set volume value. From 0 to 30
   myDFPlayer.volume(20);  //Set volume value. From 0 to 30
// myDFPlayer.play(1);  //Play the first mp3
  myDFPlayer.play(1);  //Play the first mp3
   myDFPlayer.loop(1);
   myDFPlayer.enableLoop();
  //myDFPlayer.loop(1);




   //int analogPin = 11;
    
   pinMode (11, OUTPUT);
   pinMode (11, OUTPUT);
   int val = 51;
   int val = 51;
   
   
   //for (int i = 0; i < 100; i++) {
    
     analogWrite(11, val);
     analogWrite(11, val);
  //}
 
    
    
    
    
Línea 304: Línea 307:
   delay(50);
   delay(50);


  //entre 0 y 255
/*
  if (difference > 100){
    analogWrite(11, 255);
  } else {
    analogWrite(11, 0);
  }
  */
    
    
   if (difference < 0) difference = 0;
  //  limitamos entre en 0 y 255
   if (difference < 0) difference = 0;  
   if (difference > 255) difference = 255;
   if (difference > 255) difference = 255;


  analogWrite(11, difference);
analogWrite(11, difference);
}
}
</syntaxhighlight>
</syntaxhighlight>