Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Pin 13 has an LED connected on most Arduino boards.
- // give it a name:
- int sounds[] = {128, 300, 500, 800};
- int del = 800;
- // the setup routine runs once when you press reset:
- void setup() {
- // initialize the digital pin as an output.
- Serial.begin(9600);
- }
- // the loop routine runs over and over again forever:
- void loop() {
- int length = 4;
- for(int i=0; i < length; i++)
- {
- // print the results to the serial monitor:
- Serial.print("i = ");
- Serial.print(i);
- Serial.print("\t sounds = ");
- Serial.println(sounds[i]);
- // write the sound to the pin via pwm
- analogWrite(6, sounds[i]);
- delay(del);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment