Advertisement
RuiViana

Sr-V

Jan 27th, 2018
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. int led = 10;
  2. int x = 0;
  3. unsigned long tempo = 0;
  4. int meuDelay = 100;
  5. //-----------------------
  6. void setup()
  7. {
  8.   pinMode(led, OUTPUT);
  9.   Serial.begin(9600);
  10.   tempo = millis() - meuDelay;        // Ex: millis = 950, tempo = 850
  11. }
  12. //-----------------------
  13. void loop()
  14. {
  15.   for (x = 0; x <= 255; x = x + 10)
  16.   {
  17.     if ((millis() - tempo) > 100)      // Ex:  millis = 951  millis() - tempo =  101
  18.     {
  19.       analogWrite(led, x);
  20.       Serial.println(map(x, 0, 255, 0, 5));
  21.       tempo = millis();                   // Atualiza o valor de millis()
  22.       //delay(100);
  23.     }
  24.   }
  25.   //gostaria de substituir esse delay por um millis
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement