renix1

Fase média, Arduino

May 15th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #define pinBuzzer 8
  2.  
  3. int freqMax = 0;
  4.  
  5.  
  6. void setup () {
  7.   Serial.begin(9600);
  8.   pinMode(pinBuzzer, OUTPUT);
  9.  
  10.  
  11.  
  12. }
  13.  
  14. void loop () {
  15.    /*for (int freq = 0; freq < 20000; freq+=50) {
  16.       //tone(pinBuzz, freq);
  17.       noTone(pinBuzz);
  18.    }*/
  19.    freqMax = random(0, 4000);
  20.    Serial.print("A frequencia maxima: ");
  21.    Serial.println(freqMax);
  22.    short freqDiv = freqMax/4;
  23.    Serial.print("A frequencia divida por 4: ");
  24.    Serial.println(freqDiv);
  25.    for (int freqInicial = 0; freqInicial < freqMax; freqInicial+=(freqMax/4)) {
  26.       //tone(pinBuzzer, freqInicial);
  27.    }
  28.    delay(1000);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment