Grove starter kit for arduino --- Sound sensor

by Grant

  • 1,247 views
  • 0 comments
  • 4 respects

Grove starter kit for arduino --- Buzzer

by Grant

  • 807 views
  • 0 comments
  • 4 respects

Grove Starter Kit for Arduino --- Light Sensor

by Grant

  • 1,841 views
  • 0 comments
  • 2 respects


Servo

by Grant

  • 18,984 views
  • 18 comments
  • 60 respects

Relativ - Build Your Own VR Headset for $100

Project showcase by Team Relativty

  • 37,899 views
  • 21 comments
  • 127 respects

Master Slave I2C Connection

by PIYUSH_K_SINGH

  • 19,173 views
  • 1 comment
  • 13 respects

  • Piezo "happy birthday" almost 2 years 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" almost 2 years 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 about 2 years 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