Here I have used common cathode configuration , 7-segment pins a,b.c...g are connected to 4,5,6...10 digital pins of arduino board.
int pd2=3;
//Photodiode to digital pin 2 and pin 3
int led=13; //led to digital pin 9
int pd1Read=0; //Readings from sensor to analog pin 0
int pd2Read=1;
int limit1=975;//Threshold range of an obstacle
int limit2=975;
int flag=0;
int count=0;
const int segment[]={4,5,6,7,8,9,10};
void setup()
{ for(int i=0;i<7;i++)
{
pinMode(segment[i],OUTPUT);
}
pinMode(pd1,OUTPUT);
pinMode(pd2,OUTPUT);
pinMode(led,OUTPUT);
digitalWrite(pd1,HIGH); //supply 5 volts to photodiode
digitalWrite(pd2,HIGH);
digitalWrite(led,LOW); //set the led in off mode (initial condition)
Serial.begin(9600); //setting serial monitor at a default baund rate of 9600
}
void loop()
{
int val1=analogRead(pd1Read); //variable to store values from the photodiode 1
int val2=analogRead(pd2Read);
// const byte segmentnumbers[]={B1111110,B0110000,B1101101,B1111001,B0110011,B1011011,B1011111,B1110000,B1111111,B1111011};
if(val1<=limit1)
{count=count+1;
//digitalWrite(led,HIGH);
}
delay(500);
if(val2<=limit2)
{count=count-1;
if(count==-1)
count=0;
}
for(int i=0;i<7;i++)
{
digitalWrite(segment[i],LOW);
}
// delay(100);
switch(count)
{case 0:
for(int i=0;i<6;i++)
digitalWrite(segment[i],HIGH);
break;
case 1:
digitalWrite(segment[1],HIGH);
digitalWrite(segment[2],HIGH);
break;
case 2:
digitalWrite(segment[0],HIGH);
digitalWrite(segment[1],HIGH);
digitalWrite(segment[3],HIGH);
digitalWrite(segment[4],HIGH);
digitalWrite(segment[6],HIGH);
break;
case 3:
digitalWrite(segment[0],HIGH);
digitalWrite(segment[1],HIGH);
digitalWrite(segment[3],HIGH);
digitalWrite(segment[2],HIGH);
digitalWrite(segment[6],HIGH);
break;
case 4:
digitalWrite(segment[2],HIGH);
digitalWrite(segment[1],HIGH);
digitalWrite(segment[5],HIGH);
digitalWrite(segment[6],HIGH);
break;
case 5:
digitalWrite(segment[0],HIGH);
digitalWrite(segment[2],HIGH);
digitalWrite(segment[3],HIGH);
digitalWrite(segment[5],HIGH);
digitalWrite(segment[6],HIGH);
break;
case 6:
for(int i=0;i<7;i++)
if(i!=1)
digitalWrite(segment[i],HIGH);
break;
case 7: digitalWrite(segment[0],HIGH);
digitalWrite(segment[1],HIGH);
digitalWrite(segment[2],HIGH);
break;
case 8:
for(int i=0;i<7;i++)
digitalWrite(segment[i],HIGH);
break;
case 9:
for(int i=0;i<7;i++)
if(i!=4)
digitalWrite(segment[i],HIGH);
break;
}
if(count==0)
{digitalWrite(led,LOW);
}
else
{
digitalWrite(led,HIGH);
}
delay(50);
}
hello, can u pls email me ur schematic design because ur project is very interesting...i would like to try... this is my email fablincyrasin@gmail.com
ReplyDeletehi !
ReplyDeleteIt's truly awesome project! However how to set the entry and exit sensors at the same door...?
because we use the same door for entering/leaving the room....?
Akhil kapoor
akhil.kapz@gmail.com
if entry and exit sensors are at the same door , code should be modified such that if entry sensor detects a person first, then exit sensor reading should be avoided for few seconds and count should be incremented .similarly if exit sensor first detects the person , entry sensor reading should be avoided for some seconds and count should be decremented. Note: Sometimes the circuit may not work properly if exposed to more sunlight , so it is preferable to do this in the place where there is very less or no sunlight.
ReplyDeleteFor IR sensor to work better in sunlight, u can cover the IR with a black cap or a small plastic enclosure and leave only the front end open.
can you please post the said changes in the code when the sensors are placed in the same door. this would be really helpful for the project I'm working on right now. thanks in advance.
Deletecan u plzzz write the changes in the code for the above problem
ReplyDeletePlease can the 1.5k resistor be replaced with a 1k ohms resistor ??
ReplyDeleteHi, can you program an arduino chip for me. I can build the hardware but have no skill in programming. I will pay for arduino chip, programming service and shipping to philippines. Please let me know. thanks, jtence@gmail.com
ReplyDeletepls share me the circuit diagram n full prohect descriptionnn
ReplyDeletepls share me the circuit diagram n full prohect descriptionnn my email id: akashmkashyap.357@gmail.com
ReplyDelete