Name of study: AUTOMATIC ELECTRIC FAN
We used an ultrasonic sensor for the switching on/off of our Fan and an LM35 SENSOR to control the speed regulation. During our experiment, we use a LED instead of a Fan before we proceed to fan. Here is our code:
Description: Codes for LM35 Sensor using LED and Arduino Uno as Microcontroller)
#define led 9
float temp;
void setup ()
{
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop ()
{
temp = analogRead (A0);
temp = temp*0.48828125;
if (temp < 31 )
{
digitalWrite(led, HIGH);
}
else {
digitalWrite(led, LOW);
}
Serial.print("TEMPERATURE: ");
Serial.print(temp);
Serial.print("*C");
Serial.println();
delay(1000);
}
Description: Code for ULTRASONIC SENSOR using two LED’s AND Arduinbo Uno as Microcontroller
#define trigPin 13
#define echoPin 12
#define led 6
#define led 5
{
digitalWrite(trigPin, LOW);
delayMicroseconds (2);
digitalWrite(trigPin, HIGH);
delayMicroseconds (10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration*0.034/2;
if (distance < 100 )
{
digitalWrite(led, HIGH);
}
else {
digitalWrite(led, LOW);
}
Serial.print("Distance:");
Serial.println(distance);
Serial.print("cm");
delay(1000);
}
{}
. That will format the code so that it's readable. Right now it is decidedly not readable. – Duncan C Mar 8 at 15:45