Arduino Rüzgar Sensörü #Anemometre

Arduino Rüzgar Sensörü #Anemometre

Rüzgarın Hızını ölçüp yorumlamak için kullanılan Anemometre yi arduino ile birleştirdim.

Rüzgar sensörü olarak ta bilinen arkadaşımız her turda bir pals üretir. İki adet ucu vardır. Bu uçların birinden 5v uygulanır diğer uçtan ise her bir turda 5v çıkış verir. Bu çıkışı kullanarak saniyede kaç defa tur attığını tespit edeceğiz. Ayrıca devrede bulunan pot sayesinde referans değeri girişi yaparak . Tur sayısı bu değerin üzerine çıkarsa buzzerden uyarı verecek.

Rüzgar Ölçüm projemde ekran olarak 7 segment display kullanılmıştır. Projede istenen display olduğundan lcd yerine tercih edildi.

12 bacaklı display;

 

 

 


int led[1]={A1};

//display pins

int segA = 5;  // >>  11
int segB = 13; // >>  7
int segC = 10; // >>  4
int segD = 8;  // >>  2
int segE = 7;  // >>  1
int segF = 4;  // >>  10
int segG = 11; // >>  5
int segPt = 9; // >>  3
//------------//

//display digit
int d1 = 6;   // >> 12
int d2 = 3;   // >> 9
int d3 = 2;   // >> 8
int d4 = 12;  // >> 6
//------------//

int delayTime = 5000; //delayTime <Don't change it, if you don't know where is it!>

int i=0;
int q=0;
int w=0;
int e=0;
int r=0;
//=============================================//
//init all pin used
void setup() {

  
pinMode(led[0], OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
}



//=============================================//
void loop() {

writeN(q,w,e,r);
  int SolTarafEngel = analogRead(A0);
  int solengel = map(abs(SolTarafEngel), 0, 1024, 0, 100);


if (solengel < 50)
  {
arttir();

}



if (solengel > 50)
  {
azalt();

}














if(w>=1 && e>=0 && r>=0 )
{
  
  digitalWrite(led[0],HIGH);
}
else
{
  
  digitalWrite(led[0],LOW);
}



}

//=============================================//
//Write a Number - writeN(1,9,9,0) -> 1990
void writeN(int a,int b,int c,int d){
    selectDwriteL(1,a);
    selectDwriteL(2,b);
    selectDwriteL(3,c);
    selectDwriteL(4,d);
}

//=============================================//
//Make a Number Number Countdown (Timers).
void down(int a,int b,int c,int d){
  while (a != -1) {
    while(b != -1){
      while(c != -1){
        while (d != -1) {
          while (i<10) { // i here is like a timer ! because we can't use delay function
            selectDwriteL(1,a);
            selectDwriteL(2,b);
            selectDwriteL(3,c);
            selectDwriteL(4,d);
            i++;
          }
          i=0;
          d--;
        }
        d=9;
        c--;
      }
      c=9;
      b--;
    }
    b=9;
    a--;
    }
}

//=============================================//
//Select Wich Digit (selectD) is going to Display (writeL)
void selectDwriteL(int d,int l){
  switch (d) { // choose a digit
    case 0: digitalWrite(d1, LOW); //case 0 - All ON
            digitalWrite(d2, LOW);
            digitalWrite(d3, LOW);
            digitalWrite(d4, LOW);
            break;
    case 1: digitalWrite(d1, LOW);//case 1 - Digit Number 1
            digitalWrite(d2, HIGH);
            digitalWrite(d3, HIGH);
            digitalWrite(d4, HIGH);
            break;
    case 2: digitalWrite(d1, HIGH);//case 1 - Digit Number 2
            digitalWrite(d2, LOW);
            digitalWrite(d3, HIGH);
            digitalWrite(d4, HIGH);
            break;
    case 3: digitalWrite(d1, HIGH);//case 1 - Digit Number 3
            digitalWrite(d2, HIGH);
            digitalWrite(d3, LOW);
            digitalWrite(d4, HIGH);
            break;
    case 4: digitalWrite(d1, HIGH);//case 1 - Digit Number 4
            digitalWrite(d2, HIGH);
            digitalWrite(d3, HIGH);
            digitalWrite(d4, LOW);
            break;
  }

  switch (l) { // choose a Number
    case 0: zero();
            break;
    case 1: one();
            break;
    case 2: two();
            break;
    case 3: three();
            break;
    case 4: four();
            break;
    case 5: five();
            break;
    case 6: six();
            break;
    case 7: seven();
            break;
    case 8: eight();
            break;
    case 9: nine();
            break;
    case 10: point(); // print a Point
            break;
    case 11: none(); // make all them off !
            break;
  }

delayMicroseconds(delayTime); // delayTime for nice display of the Number !

}

//=============================================//
//shown one Number in the 4 Digit
void all(int n){
  selectDwriteL(0,n);
}

//=============================================//
void zero(){
  digitalWrite(segA, HIGH);
  digitalWrite(segB, HIGH);
  digitalWrite(segC, HIGH);
  digitalWrite(segD, HIGH);
  digitalWrite(segE, HIGH);
  digitalWrite(segF, HIGH);
  digitalWrite(segG, LOW);
  digitalWrite(segPt, LOW);
}
//=============================================//
void one(){
  digitalWrite(segA, LOW);
  digitalWrite(segB, HIGH);
  digitalWrite(segC, HIGH);
  digitalWrite(segD, LOW);
  digitalWrite(segE, LOW);
  digitalWrite(segF, LOW);
  digitalWrite(segG, LOW);
  digitalWrite(segPt, LOW);
}
//=============================================//
void two(){
  digitalWrite(segA, HIGH);
  digitalWrite(segB, HIGH);
  digitalWrite(segC, LOW);
  digitalWrite(segD, HIGH);
  digitalWrite(segE, HIGH);
  digitalWrite(segF, LOW);
  digitalWrite(segG, HIGH);
  digitalWrite(segPt, LOW);
}
//=============================================//
void three(){
  digitalWrite(segA, HIGH);
  digitalWrite(segB, HIGH);
  digitalWrite(segC, HIGH);
  digitalWrite(segD, HIGH);
  digitalWrite(segE, LOW);
  digitalWrite(segF, LOW);
  digitalWrite(segG, HIGH);
  digitalWrite(segPt, LOW);
}
//=============================================//
void four(){
  digitalWrite(segA, LOW);
  digitalWrite(segB, HIGH);
  digitalWrite(segC, HIGH);
  digitalWrite(segD, LOW);
  digitalWrite(segE, LOW);
  digitalWrite(segF, HIGH);
  digitalWrite(segG, HIGH);
  digitalWrite(segPt, LOW);
}
//=============================================//
void five(){
  digitalWrite(segA, HIGH);
  digitalWrite(segB, LOW);
  digitalWrite(segC, HIGH);
  digitalWrite(segD, HIGH);
  digitalWrite(segE, LOW);
  digitalWrite(segF, HIGH);
  digitalWrite(segG, HIGH);
  digitalWrite(segPt, LOW);
}
//=============================================//
void six(){
  digitalWrite(segA, HIGH);
  digitalWrite(segB, LOW);
  digitalWrite(segC, HIGH);
  digitalWrite(segD, HIGH);
  digitalWrite(segE, HIGH);
  digitalWrite(segF, HIGH);
  digitalWrite(segG, HIGH);
  digitalWrite(segPt, LOW);
}
//=============================================//
void seven(){
  digitalWrite(segA, HIGH);
  digitalWrite(segB, HIGH);
  digitalWrite(segC, HIGH);
  digitalWrite(segD, LOW);
  digitalWrite(segE, LOW);
  digitalWrite(segF, LOW);
  digitalWrite(segG, LOW);
  digitalWrite(segPt, LOW);
}
//=============================================//
void eight(){
  digitalWrite(segA, HIGH);
  digitalWrite(segB, HIGH);
  digitalWrite(segC, HIGH);
  digitalWrite(segD, HIGH);
  digitalWrite(segE, HIGH);
  digitalWrite(segF, HIGH);
  digitalWrite(segG, HIGH);
  digitalWrite(segPt, LOW);
}
//=============================================//
void nine(){
  digitalWrite(segA, HIGH);
  digitalWrite(segB, HIGH);
  digitalWrite(segC, HIGH);
  digitalWrite(segD, HIGH);
  digitalWrite(segE, LOW);
  digitalWrite(segF, HIGH);
  digitalWrite(segG, HIGH);
  digitalWrite(segPt, LOW);
}
//=============================================//
void point(){
  digitalWrite(segA, LOW);
  digitalWrite(segB, LOW);
  digitalWrite(segC, LOW);
  digitalWrite(segD, LOW);
  digitalWrite(segE, LOW);
  digitalWrite(segF, LOW);
  digitalWrite(segG, LOW);
  digitalWrite(segPt, HIGH);
}
//=============================================//
void none(){
  digitalWrite(segA, LOW);
  digitalWrite(segB, LOW);
  digitalWrite(segC, LOW);
  digitalWrite(segD, LOW);
  digitalWrite(segE, LOW);
  digitalWrite(segF, LOW);
  digitalWrite(segG, LOW);
  digitalWrite(segPt, LOW);
}

void arttir()
{
  r++;
if(r>9)
{
  r=0;
  e++;

if(e>9)
{
e=0;
w++;

if(w>9)
{

w=0;
q++;
if(q==9)
{
q=0;
w=0;
e=0;
r=0;
  
}
}
}
}
}



void azalt()
{
  r--;
if(r==0)
{
  r=9;
  e--;

if(e==0)
{
e=9;
w--;

if(w==0)
{

w=9;
q--;
if(q==0)
{
q=0;
w=0;
e=0;
r=0;
  
}
}
}
}
}






Sosyal Medyada Paylaş Facebook Twitter Google+

Etiketler: , , , , , ,
Eklenme Tarihi: 31 Ocak 2018

Konu hakkında yorumunuzu yazın