marzanogreg
Published

Clarinet Companion

Keep your reeds in the correct humidity range and tune to a concert A at 440 Hz.

IntermediateShowcase (no instructions)102
Clarinet Companion

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
5 mm LED: Green
5 mm LED: Green
×1
5 mm LED: Red
5 mm LED: Red
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Speaker, Piezo
Speaker, Piezo
×1
Pushbutton Switch, Momentary
Pushbutton Switch, Momentary
×1
Breadboard (generic)
Breadboard (generic)
×2
Resistor 220 ohm
Resistor 220 ohm
×2
Resistor 1k ohm
Resistor 1k ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

sketch_gregfinal.ino

C/C++
#include <DHT.h>
#include <DHT_U.h>
#include <LiquidCrystal.h> 
#include <Adafruit_Sensor.h>
//libraries

#define DHTPIN 11 

#define DHTTYPE DHT11   // DHT 11

DHT dht = DHT(DHTPIN, DHTTYPE);

// Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
LiquidCrystal lcd(1, 0, 8, 5, 4, 3);

const byte buttonPin = 2; 
volatile byte state = LOW;
int buttonState = 0;
volatile int i = 0;

void setup()
{
  lcd.begin(16,2); //Set up the LCD

  dht.begin();
  
  pinMode(9, OUTPUT); //Piezo Speaker GREY WIRE
  
  pinMode(2, INPUT);
  attachInterrupt(digitalPinToInterrupt(2), sound, RISING);
  
  pinMode(13, OUTPUT); //RED LED BROWN WIRE
  pinMode(12, OUTPUT); //GREEN LED BROWN WIRE
}

void loop()
{
  
  float h = dht.readHumidity();

  lcd.setCursor(0,0);
  lcd.print("Humidity Level: ");
  lcd.setCursor(5,2);
  lcd.print(h); //humidity level variable 
  lcd.print("%");
  lcd.setCursor(0,1);
  
  if (h < 50){
    digitalWrite(13, HIGH); 
    digitalWrite(12, LOW); 
  }
  else if (h < 80) {
    digitalWrite(12, HIGH);
    digitalWrite(13, LOW);
  }
  else{
    digitalWrite(13, HIGH); 
    digitalWrite(12, LOW); 
  }

  delay(5000);

}

void sound()
{
      tone(9, 440, 6000); //A440 Tone

}

Credits

marzanogreg
0 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.