solkit
Published © Apache-2.0

Automated Mung Bean Sprouts Growing Machine

Automated Mung Bean Sprouts growing machine.

BeginnerShowcase (no instructions)4,221
Automated Mung Bean Sprouts Growing Machine

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Relay (generic)
×1
12 VDC Power Supply (generic)
×2
barrel jack (generic)
×2
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
12V mini water pump
×1
Tubing (generic)
×1

Story

Read more

Schematics

Circuit diagram

Circuit diagram

Code

Automated Mung Bean Sprouts Growing Machine Code

C/C++
Sketch Code
 Source Code


/*
* For Automated Mung Bean Sprouts growing machine
*
* Watering every 2 hours
* play music when watering
*
 * Relay pin 12
* speaker pin 8
*
 * created 22 Jan 2017
*
 *by Douglas Changsoo Park
*
 */
 
#include <SimpleTimer.h>
#include "pitches.h"
 
int relay = 12;
 
SimpleTimer timer;
 
int melody[] = {
  NOTE_G4,
  NOTE_G4,
  NOTE_A4,
  NOTE_A4,
  NOTE_G4,
  NOTE_G4,
  NOTE_E4,
  NOTE_G4,
  NOTE_G4,
  NOTE_E4,
  NOTE_E4,
  NOTE_D4,
  0,
  NOTE_G4,
  NOTE_G4,
  NOTE_A4,
  NOTE_A4,
  NOTE_G4,
  NOTE_G4,
  NOTE_E4,
  NOTE_G4,
  NOTE_E4,
  NOTE_D4,
  NOTE_E4,
  NOTE_C4,
  0 };
 
  int noteDurations[] = {
  1,1,1,1,
  1,1,2,
  1,1,1,1,
  3,1,
  1,1,1,1,
  1,1,2,
  1,1,1,1,
  3,1
  };
 
void setup() {
  // put your setup code here, to run once:
  pinMode(relay, OUTPUT);
 digitalWrite(relay, HIGH);
  timer.setInterval(7200000, watering);

}
 
void loop() {
  // put your main code here, to run repeatedly:
  timer.run();
}
 
void watering() {
  digitalWrite(relay, LOW);
  music();

  music();

  digitalWrite(relay, HIGH);
  noTone(8);
}
 
void music() {
  for(int thisNote = 0; thisNote < 26; thisNote++) {
      int noteDuration = 250 * noteDurations[thisNote];
      tone(8, melody[thisNote], noteDuration);
      int pauseBetweenNotes = noteDuration * 1.30;
      delay(pauseBetweenNotes);
      noTone(8);
  }
}

Updated Source Code

C/C++
Source code has been updated
/*
* For Automated Mung Bean Sprouts growing machine
*
* Watering every 2 hours
* play music when watering
*
 * Relay pin 12
* speaker pin 8
*
 * created 22 Jan 2017
 * 
 * updated 24 Jan 2017
 * -Added one more song (Butterfly)
 * -Randomly select a song (Schoolbell or Butterfly)
 * -watering every an hour from every 2 hours.
 * -increase watering time (Schoolbell - play 3 times, Butterfly - play 2 times)
*
 *by Douglas Changsoo Park
*
 */
 
#include <SimpleTimer.h>
#include "pitches.h"
 
int relay = 12;
int melodyPin = 8;
 
SimpleTimer timer;
 
int schoolbell_melody[] = {
  NOTE_G4,  NOTE_G4,  NOTE_A4,  NOTE_A4,  NOTE_G4,  NOTE_G4,  NOTE_E4,  NOTE_G4,  NOTE_G4,  NOTE_E4,  NOTE_E4,  NOTE_D4,  0,
  NOTE_G4,  NOTE_G4,  NOTE_A4,  NOTE_A4,  NOTE_G4,  NOTE_G4,  NOTE_E4,  NOTE_G4,  NOTE_E4,  NOTE_D4,  NOTE_E4,  NOTE_C4,  0 };
 
int schoolbell_noteDurations[] = {  1,1,1,1,  1,1,2,  1,1,1,1,  3,1,  1,1,1,1,  1,1,2,  1,1,1,1,  3,1  };

int butterfly_melody[] = {
  NOTE_G4,NOTE_E4,NOTE_E4,NOTE_F4,NOTE_D4,NOTE_D4,NOTE_C4,NOTE_D4,NOTE_E4,NOTE_F4,NOTE_G4,NOTE_G4,NOTE_G4,
  NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4,NOTE_F4,NOTE_D4,NOTE_D4,NOTE_C4,NOTE_E4,NOTE_G4,NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4,0,
  NOTE_D4,NOTE_D4,NOTE_D4,NOTE_D4,NOTE_D4,NOTE_E4,NOTE_F4,NOTE_E4,NOTE_E4,NOTE_E4,NOTE_E4,NOTE_E4,NOTE_F4,NOTE_G4,
  NOTE_G4,NOTE_E4,NOTE_E4,NOTE_F4,NOTE_D4,NOTE_D4,NOTE_C4,NOTE_E4,NOTE_G4,NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4,0
};

int butterflyNoteDurations[] = {
  1,1,2,1,1,2, 1,1,1,1,1,1,2,  1,1,1,1,1,1,2, 1,1,1,1,1,1,3,1,
  1,1,1,1,1,1,2,1,1,1,1,1,1,2,  1,1,2,1,1,2,1,1,1,1,1,1,3,1
};

void setup() {
  // put your setup code here, to run once:
  pinMode(relay, OUTPUT);
 digitalWrite(relay, HIGH);
  //timer.setInterval(7200000, watering);
  timer.setInterval(3600000, watering);
  //timer.setInterval(25000, watering); // Test Mode
}
 
void loop() {
  // put your main code here, to run repeatedly:
  timer.run();
}
 
void watering() {
  digitalWrite(relay, LOW);
  int song = random(1,3);
  if(song == 1) {
    music_schoolBell();
    music_schoolBell();
    music_schoolBell();
  } else {
    music_butterfly();
    music_butterfly();
  }
  digitalWrite(relay, HIGH);
  noTone(8);
}
 
void music_schoolBell() {
    int size = sizeof(schoolbell_melody) / sizeof(int);
  for(int thisNote = 0; thisNote < size; thisNote++) {
      int noteDuration = 250 * schoolbell_noteDurations[thisNote];
      tone(melodyPin, schoolbell_melody[thisNote], noteDuration);
      int pauseBetweenNotes = noteDuration * 1.30;
      delay(pauseBetweenNotes);
      noTone(melodyPin);
  }
}

void music_butterfly(){
  int size = sizeof(butterfly_melody) / sizeof(int);
  for (int thisNote = 0; thisNote < size; thisNote++) {
      int noteDuration = 250 * butterflyNoteDurations[thisNote];
      tone(melodyPin, butterfly_melody[thisNote], noteDuration);
      int pauseBetweenNotes = noteDuration * 1.30;
      delay(pauseBetweenNotes);
      noTone(melodyPin);
  }
}

Credits

solkit

solkit

2 projects • 2 followers

Comments