This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reference: This list was adapted from the table located here: | |
// http://www.phy.mtu.edu/~suits/notefreqs.html | |
const float note_C0 = 16.35; //C0 | |
const float note_Db0 = 17.32; //C#0/Db0 | |
const float note_D0 = 18.35; //D0 | |
const float note_Eb0 = 19.45; //D#0/Eb0 | |
const float note_E0 = 20.6; //E0 | |
const float note_F0 = 21.83; //F0 | |
const float note_Gb0 = 23.12; //F#0/Gb0 | |
const float note_G0 = 24.5; //G0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "notes.h" // adds the notes.h | |
int speakerPin = 9;// pins defined as variables | |
int tiltPin = 2;// cause they are used many times in the program | |
void setup() { | |
pinMode(speakerPin, OUTPUT);// pin 9 piezo speaker - output | |
pinMode(tiltPin, INPUT_PULLUP);// pin 2 tilt switch - input | |
Serial.begin(9600);// debugging helps! | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//function to produce the sounds | |
void beep (int speakerPin, float noteFrequency, long noteDuration) | |
{ | |
int x; // Convert the frequency to microseconds | |
float microsecondsPerWave = 1000000/noteFrequency; // Calculate how many HIGH/LOW cycles there are per millisecond | |
float millisecondsPerCycle = 1000/(microsecondsPerWave * 2);// Multiply noteDuration * number or cycles per millisecond | |
float loopTime = noteDuration * millisecondsPerCycle; // Play the note for the calculated loopTime. | |
for (x=0;x<loopTime;x++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//sketch designed for the resistive moisture sensor YL-69 sensor. | |
//it's recommended to use this sensor without a continuous VCC | |
int moistReadpin = A0; //moist sensor reading pin | |
int pumpPin = 2; //triggers pump to work | |
int okLED = 5; //good moist light pin | |
int wateringLED = 6; //watering light pin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//sketch designed for the resistive moisture sensor YL-69 sensor. | |
//it's recommended to use this sensor without a continuous VCC | |
int moistReadpin = A0; //moist_sens reading pin | |
int moistPowerpin = 3; //moist_sens power pin | |
int pumpPin = 2; //triggers pump to work | |
int okLED = 5; //ideal moist light pin | |
int wateringLED = 6; //watering light pin |