Hello
My project :
- I want to add to counter when a person is entering.
- Deduct when leaving.
- Will detect temperature in room via LM35.
- According to person entering the room, will adjust the temperature reading.
e.g : 6 person in rooms. = 3 degree rise in temperature.
0.5 degree rise in temperature for each person. ( JUST TO PRINT IT ON SCREEN)
e.g 2 : Actual Temp reading = 34 C . but if 6 person are in room then temp will be shown as 37 C .
5 ) with the FAKE TEMP reading i would control the speed of fan.
Print all the data on LCD. ( Person Count and FakeTemp Reading)
ONLY THEORY
To achieve the person count . Initially i was using a 2 LDR .
LDR 1 , LDR2 are mounted closely to each other. and a laser beam has to be thrown onto it.
If LDR1 is cut and then shortly LDR2 is cut. Then person+=1 .
If LDR2 is cut and then shortly LDR1 is cut. then person-=1.
But due to ignorance. I tied LDR to digital pins, Thinking that when person will cut the pin will go low and vice versa.
Now, I want to use HALL EFFECT SENSOR and attach magnets to the door ( DOOR with PUSH when entering and PULL WHEN LEAVING)
hence i want to know how can i use HALL EFFECT sensor as a switch on digital pin without interrupt.
I did use half effect sensor on a running engine to measure RPM but that was using interrupt .
I have designed my PCB and fabricated it and don't want to spend time creating another one as i mistakenly used hardware interrupt pins as I/O for LCD.
EDIT : I am using standalone ATMEGA328( not 328p) with internal 8MHz oscillator, programmed via ArduinoToBreadboard example and tinkering.
Here is the code , eagle schematic and PCB .
#include<LiquidCrystal.h>
LiquidCrystal lcd(0,1,2,3,4,5);
int ldr1=9;
int ldr2=10;
int tempsens=A0;
int fan=11;
int PWMOutput=0;
int person=0;
int temp=0;
int count=0;
float count1;
int temp1;
void setup()
{
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
pinMode(ldr1,INPUT);
pinMode(ldr2,INPUT);
pinMode(tempsens,INPUT);
pinMode(fan,OUTPUT);
}
void loop()
{
temp = (5.0 * analogRead(tempsens) * 100.0) / 1024;
if(temp>0){
fan1();
count=person;
count1=count*0.5;
temp1=temp+count1;
lcd.setCursor(0,1);
lcd.print("Temp:");
lcd.print(temp1);
lcd.write(0b11011111);
lcd.print("C");
}
if(digitalRead(ldr1)==HIGH&&digitalRead(ldr2)==LOW)
{
delay(100);
if(digitalRead(ldr1)==LOW&&digitalRead(ldr2)==HIGH)
{person+=1;
}
}
if(digitalRead(ldr2)==HIGH&&digitalRead(ldr1)==LOW)
{
delay(100);
if(digitalRead(ldr2)==LOW&&digitalRead(ldr1)==HIGH)
{person-=1;
}
}
if(ldr1==LOW&&ldr2==LOW);
{
print1();
}
void print1()
{
lcd.setCursor(0,0);
lcd.print("Person:");
lcd.print(person);
}
void fan1()
{
if(temp<=32)
PWMOutput=0;
if(temp>32&&temp<=37)
PWMOutput=100;
if(temp>37&&temp<=40)
PWMOutput=130;
if(temp>40&&temp<=45)
PWMOutput=160;
if(temp>45&&temp<=50)
PWMOutput=190;
if(temp>50&&temp<=55)
PWMOutput=220;
if(temp>55&&temp<=60)
PWMOutput=240;
if(temp>=60)
PWMOutput=255;
analogWrite(fan, PWMOutput);
}