Components and supplies
Breadboard (generic)
Jumper wires (generic)
12V mini water pump
barrel jack (generic)
Relay (generic)
12 VDC Power Supply (generic)
Tubing (generic)
Arduino UNO
Project description
Code
Updated Source Code
c_cpp
Source code has been updated
1/* 2* For Automated Mung Bean Sprouts growing machine 3* 4* Watering every 2 hours 5* play music when watering 6* 7 * Relay pin 12 8* speaker pin 8 9* 10 * created 22 Jan 2017 11 * 12 * updated 24 Jan 2017 13 * -Added one more song (Butterfly) 14 * -Randomly select a song (Schoolbell or Butterfly) 15 * -watering every an hour from every 2 hours. 16 * -increase watering time (Schoolbell - play 3 times, Butterfly - play 2 times) 17* 18 *by Douglas Changsoo Park 19* 20 */ 21 22#include <SimpleTimer.h> 23#include "pitches.h" 24 25int relay = 12; 26int melodyPin = 8; 27 28SimpleTimer timer; 29 30int schoolbell_melody[] = { 31 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, 32 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 }; 33 34int 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 }; 35 36int butterfly_melody[] = { 37 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, 38 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, 39 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, 40 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 41}; 42 43int butterflyNoteDurations[] = { 44 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, 45 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 46}; 47 48void setup() { 49 // put your setup code here, to run once: 50 pinMode(relay, OUTPUT); 51 digitalWrite(relay, HIGH); 52 //timer.setInterval(7200000, watering); 53 timer.setInterval(3600000, watering); 54 //timer.setInterval(25000, watering); // Test Mode 55} 56 57void loop() { 58 // put your main code here, to run repeatedly: 59 timer.run(); 60} 61 62void watering() { 63 digitalWrite(relay, LOW); 64 int song = random(1,3); 65 if(song == 1) { 66 music_schoolBell(); 67 music_schoolBell(); 68 music_schoolBell(); 69 } else { 70 music_butterfly(); 71 music_butterfly(); 72 } 73 digitalWrite(relay, HIGH); 74 noTone(8); 75} 76 77void music_schoolBell() { 78 int size = sizeof(schoolbell_melody) / sizeof(int); 79 for(int thisNote = 0; thisNote < size; thisNote++) { 80 int noteDuration = 250 * schoolbell_noteDurations[thisNote]; 81 tone(melodyPin, schoolbell_melody[thisNote], noteDuration); 82 int pauseBetweenNotes = noteDuration * 1.30; 83 delay(pauseBetweenNotes); 84 noTone(melodyPin); 85 } 86} 87 88void music_butterfly(){ 89 int size = sizeof(butterfly_melody) / sizeof(int); 90 for (int thisNote = 0; thisNote < size; thisNote++) { 91 int noteDuration = 250 * butterflyNoteDurations[thisNote]; 92 tone(melodyPin, butterfly_melody[thisNote], noteDuration); 93 int pauseBetweenNotes = noteDuration * 1.30; 94 delay(pauseBetweenNotes); 95 noTone(melodyPin); 96 } 97} 98 99
Automated Mung Bean Sprouts Growing Machine Code
c_cpp
Sketch Code
1※ Source Code 2 3 4/* 5* For Automated Mung Bean Sprouts growing 6 machine 7* 8* Watering every 2 hours 9* play music when watering 10* 11 12 * Relay pin 12 13* speaker pin 8 14* 15 * created 22 Jan 2017 16* 17 *by Douglas 18 Changsoo Park 19* 20 */ 21 22#include <SimpleTimer.h> 23#include "pitches.h" 24 25 26int relay = 12; 27 28SimpleTimer timer; 29 30int melody[] = { 31 NOTE_G4, 32 33 NOTE_G4, 34 NOTE_A4, 35 NOTE_A4, 36 NOTE_G4, 37 NOTE_G4, 38 NOTE_E4, 39 40 NOTE_G4, 41 NOTE_G4, 42 NOTE_E4, 43 NOTE_E4, 44 NOTE_D4, 45 0, 46 NOTE_G4, 47 48 NOTE_G4, 49 NOTE_A4, 50 NOTE_A4, 51 NOTE_G4, 52 NOTE_G4, 53 NOTE_E4, 54 55 NOTE_G4, 56 NOTE_E4, 57 NOTE_D4, 58 NOTE_E4, 59 NOTE_C4, 60 0 }; 61 62 63 int noteDurations[] = { 64 1,1,1,1, 65 1,1,2, 66 1,1,1,1, 67 3,1, 68 69 1,1,1,1, 70 1,1,2, 71 1,1,1,1, 72 3,1 73 }; 74 75void setup() { 76 77 // put your setup code here, to run once: 78 pinMode(relay, OUTPUT); 79 digitalWrite(relay, 80 HIGH); 81 timer.setInterval(7200000, watering); 82 83} 84 85void loop() { 86 87 // put your main code here, to run repeatedly: 88 timer.run(); 89} 90 91void 92 watering() { 93 digitalWrite(relay, LOW); 94 music(); 95 96 music(); 97 98 99 digitalWrite(relay, HIGH); 100 noTone(8); 101} 102 103void music() { 104 for(int 105 thisNote = 0; thisNote < 26; thisNote++) { 106 int noteDuration = 250 * noteDurations[thisNote]; 107 108 tone(8, melody[thisNote], noteDuration); 109 int pauseBetweenNotes = 110 noteDuration * 1.30; 111 delay(pauseBetweenNotes); 112 noTone(8); 113 114 } 115}
Automated Mung Bean Sprouts Growing Machine Code
c_cpp
Sketch Code
1※ Source Code 2 3 4/* 5* For Automated Mung Bean Sprouts growing machine 6* 7* Watering every 2 hours 8* play music when watering 9* 10 * Relay pin 12 11* speaker pin 8 12* 13 * created 22 Jan 2017 14* 15 *by Douglas Changsoo Park 16* 17 */ 18 19#include <SimpleTimer.h> 20#include "pitches.h" 21 22int relay = 12; 23 24SimpleTimer timer; 25 26int melody[] = { 27 NOTE_G4, 28 NOTE_G4, 29 NOTE_A4, 30 NOTE_A4, 31 NOTE_G4, 32 NOTE_G4, 33 NOTE_E4, 34 NOTE_G4, 35 NOTE_G4, 36 NOTE_E4, 37 NOTE_E4, 38 NOTE_D4, 39 0, 40 NOTE_G4, 41 NOTE_G4, 42 NOTE_A4, 43 NOTE_A4, 44 NOTE_G4, 45 NOTE_G4, 46 NOTE_E4, 47 NOTE_G4, 48 NOTE_E4, 49 NOTE_D4, 50 NOTE_E4, 51 NOTE_C4, 52 0 }; 53 54 int noteDurations[] = { 55 1,1,1,1, 56 1,1,2, 57 1,1,1,1, 58 3,1, 59 1,1,1,1, 60 1,1,2, 61 1,1,1,1, 62 3,1 63 }; 64 65void setup() { 66 // put your setup code here, to run once: 67 pinMode(relay, OUTPUT); 68 digitalWrite(relay, HIGH); 69 timer.setInterval(7200000, watering); 70 71} 72 73void loop() { 74 // put your main code here, to run repeatedly: 75 timer.run(); 76} 77 78void watering() { 79 digitalWrite(relay, LOW); 80 music(); 81 82 music(); 83 84 digitalWrite(relay, HIGH); 85 noTone(8); 86} 87 88void music() { 89 for(int thisNote = 0; thisNote < 26; thisNote++) { 90 int noteDuration = 250 * noteDurations[thisNote]; 91 tone(8, melody[thisNote], noteDuration); 92 int pauseBetweenNotes = noteDuration * 1.30; 93 delay(pauseBetweenNotes); 94 noTone(8); 95 } 96}
Downloadable files
Circuit diagram
Circuit diagram
Circuit diagram
Circuit diagram
Circuit diagram
Circuit diagram
Comments
Only logged in users can leave comments
solkit
0 Followers
•0 Projects
Table of contents
Intro
4
0