Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //***************************************************************************************
- // EE40LX
- // Sketch 3.4 adapted to Arduino
- //
- //***************************************************************************************
- int BUZZER = 8; // set BUZZER as P1.3 alias
- int val;
- void setup()
- {
- // set BUZZER as output pin
- pinMode(BUZZER, OUTPUT);
- // random analog voltage noise at analog pin 0 will seed
- // the random number generator differently every time it runs
- // otherwise, we will hear the same pseudo-random sequence
- // every time we run the program (which is at times useful)
- randomSeed(analogRead(0));
- }
- void loop()
- {
- val = random(1,100); // create a random number from 1 to 100 using the Energia RNG
- if (val > 50) // if val is greater than 50, output an 800 Hz wave
- tone(BUZZER, 800, 50); // otherwise, do nothing for the same period
- else
- delay(50);
- }
- /* End of code */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement