arduino org code example
Example 1: arduino
void setup(){}
void loop(){}
Example 2: Arduino
#include <LiquidCrystal.h>
LiquidCrystal lcd(7,8,10,11,12,13);
int num_Measure = 128 ;
int pinSignal = A0;
int redLed = 5;
long Sound_signal;
long sum = 0 ;
long level = 0 ;
int soundlow = 40;
int soundmedium = 500;
void setup ()
{
pinMode (pinSignal, INPUT);
Serial.begin (9600);
lcd.begin(16,2);
}
void loop ()
{
for ( int i = 0 ; i <num_Measure; i ++)
{
Sound_signal = analogRead (pinSignal);
sum =sum + Sound_signal;
}
level = sum / num_Measure;
Serial.print("Sound Level: ");
lcd.print("Sound Level= ");
Serial.println (level-33);
lcd.print(level-33);
if(level-33<soundlow)
{
lcd.setCursor(0,2);
lcd.print("Intensity= Low");
digitalWrite(redLed,LOW);
}
if(level-33>soundlow && level-33<soundmedium)
{
lcd.setCursor(0,2);
lcd.print("Intensity=Medium");
digitalWrite(redLed,LOW);
}
if(level-33>soundmedium)
{
lcd.setCursor(0,2);
lcd.print("Intensity= High");
digitalWrite(redLed,HIGH);
}
sum = 0 ;
delay(200);
lcd.clear();
}