Grove starter kit for arduino --- Buzzer

by Grant

  • 241 views
  • 0 comments
  • 4 respects


Replicated projects 1

5vCircuitPowerMeter

Project tutorial by MicroBob

  • 1,715 views
  • 2 comments
  • 6 respects

Servo

by Grant

  • 10,431 views
  • 13 comments
  • 27 respects

Relativ - Build Your Own VR Headset for $100

Project showcase by Relativty

  • 24,843 views
  • 18 comments
  • 94 respects

Master Slave I2C Connection

by PIYUSH_K_SINGH

  • 3,849 views
  • 0 comments
  • 8 respects

  • Piezo "happy birthday" 2 months ago

    I fixed it:
    (and tried it so I know this works)

    int speakerPin = 9;
    int length = 26; // the number of notes
    char notes[] = "aabacdaabaecaahfcndbggfcec "; // a space represents a rest
    int beats[] = {2, 2, 4, 4, 4, 8, 2, 2, 4, 4, 4, 8, 2, 2, 4, 4, 4, 4, 0, 4, 3, 1, 4, 4, 4, 8, 16 };
    int tempo = 75;

    void playTone(int tone, int duration) {
    for (long i = 0; i < duration * 1000L; i += tone * 2) {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(tone);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(tone);
    }
    }
    void playNote(char note, int duration) {
    char names[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'n' };
    int tones[] = { 1515, 1351, 1136, 1205, 1012, 903, 852, 759 };
    // play the tone corresponding to the note name

    for (int i = 0; i < 8; i++) {
    if (names[i] == note) {
    playTone(tones[i], duration);
    }
    }
    }
    void setup() {
    pinMode(speakerPin, OUTPUT);
    }
    void loop() {
    for (int i = 0; i < length; i++) {
    if (notes[i] == ' ') {
    delay(beats[i] * tempo); // rest
    }
    else {
    playNote(notes[i], beats[i] * tempo);
    // pause between notes

      if (notes[i + 1] != 'n') {
        delay(tempo );
      }
      else {
        i += 2;
      }
    }
    

    }
    }

  • Piezo "happy birthday" 2 months ago

    Try this, I changed it a bit so you should be able to add a “n” between the notes that you want without a rest in between and a “0” between the beats.

    int speakerPin = 9;
    int length = 26; // the number of notes
    char notes[] = "aabacdaabaecaahfcndbggfcec "; // a space represents a rest
    int beats[] = {2,2,4,4,4,8,2,2,4,4,4,8,2,2,4,4,4,4,0,4,3,1,4,4,4,8,16 };
    int tempo = 75;

    void playTone(int tone, int duration) {
    for (long i = 0; i < duration * 1000L; i += tone * 2) {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(tone);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(tone);
    }
    }
    void playNote(char note, int duration) {
    char names[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' };
    int tones[] = { 1515, 1351, 1136, 1205, 1012, 903, 852, 759 };
    // play the tone corresponding to the note name
    for (int i = 0; i < 8; i++) {
    if (names[i] == note) {
    playTone(tones[i], duration);
    }
    }
    }
    void setup() {
    pinMode(speakerPin, OUTPUT);
    }
    void loop() {
    for (int i = 0; i < length; i++) {
    if (notes[i] == ' ') {
    delay(beats[i] * tempo); // rest
    }
    else {
    playNote(notes[i], beats[i] * tempo);
    // pause between notes

    if notes[i+1] != “n”{
    delay(tempo );
    }
    else {
    i += 1;
    }
    }
    }
    }

  • Arduino 101 Clothes Recommender 5 months ago

    This project uses the grove rgb lcd library so for this code (without alteration) you would need an i2c rgb lcd (preferably the one from grove). However, you could use any screen with a slight alteration to all of the lcd.____ lines.

Add projectSign up / Login