//from:Kundic.H.Peng 2010.5.19
//function:survey wind speed and show it on nixietube by arduino
int InPin=2;
int v=0;
int vv=0;
int q=0;
int APin=3;
int BPin=4;
int CPin=5;
int DPin=6;
int EPin=7;
int FPin=8;
int GPin=9;
int DPPin=10;
int GWPin=11;
int SWPin=12;
int BWPin=13;
int QWPin=14;
int lastTime=0;
int v=0;
int vv=0;
int q=0;
int APin=3;
int BPin=4;
int CPin=5;
int DPin=6;
int EPin=7;
int FPin=8;
int GPin=9;
int DPPin=10;
int GWPin=11;
int SWPin=12;
int BWPin=13;
int QWPin=14;
int lastTime=0;
void setup(){
Serial.begin(9600);
pinMode(InPin, INPUT);
pinMode(APin, OUTPUT);
pinMode(BPin, OUTPUT);
pinMode(CPin, OUTPUT);
pinMode(DPin, OUTPUT);
pinMode(EPin, OUTPUT);
pinMode(FPin, OUTPUT);
pinMode(GPin, OUTPUT);
pinMode(DPPin, OUTPUT);
pinMode(GWPin, OUTPUT);
pinMode(SWPin, OUTPUT);
pinMode(BWPin, OUTPUT);
pinMode(QWPin, OUTPUT);
}
Serial.begin(9600);
pinMode(InPin, INPUT);
pinMode(APin, OUTPUT);
pinMode(BPin, OUTPUT);
pinMode(CPin, OUTPUT);
pinMode(DPin, OUTPUT);
pinMode(EPin, OUTPUT);
pinMode(FPin, OUTPUT);
pinMode(GPin, OUTPUT);
pinMode(DPPin, OUTPUT);
pinMode(GWPin, OUTPUT);
pinMode(SWPin, OUTPUT);
pinMode(BWPin, OUTPUT);
pinMode(QWPin, OUTPUT);
}
void loop(){
void Show(int v);
void SMG(int m);
lastTime=millis();
while((millis()-6000)<lastTime){
v=pulseIn(InPin,HIGH);
if(v<1000){vv++;}
Show(vv);
q=q+750;
if(q>6000){break;}
}
while((millis()-100000)<lastTime){
Show((vv*2.5));}
void Show(int v);
void SMG(int m);
lastTime=millis();
while((millis()-6000)<lastTime){
v=pulseIn(InPin,HIGH);
if(v<1000){vv++;}
Show(vv);
q=q+750;
if(q>6000){break;}
}
while((millis()-100000)<lastTime){
Show((vv*2.5));}
}
void SMG(int m){
switch (m) {
case 0:
digitalWrite(APin,LOW);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,LOW);
digitalWrite(EPin,LOW);
digitalWrite(FPin,LOW);
digitalWrite(GPin,HIGH);
digitalWrite(DPPin,HIGH);
break;
case 1:
digitalWrite(APin,HIGH);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,HIGH);
digitalWrite(EPin,HIGH);
digitalWrite(FPin,HIGH);
digitalWrite(GPin,HIGH);
digitalWrite(DPPin,HIGH);
break;
case 2:
digitalWrite(APin,LOW);
digitalWrite(BPin,LOW);
digitalWrite(CPin,HIGH);
digitalWrite(DPin,LOW);
digitalWrite(EPin,LOW);
digitalWrite(FPin,HIGH);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
case 3:
digitalWrite(APin,LOW);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,LOW);
digitalWrite(EPin,HIGH);
digitalWrite(FPin,HIGH);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
case 4:
digitalWrite(APin,HIGH);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,HIGH);
digitalWrite(EPin,HIGH);
digitalWrite(FPin,LOW);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
case 5:
digitalWrite(APin,LOW);
digitalWrite(BPin,HIGH);
digitalWrite(CPin,LOW);
digitalWrite(DPin,LOW);
digitalWrite(EPin,HIGH);
digitalWrite(FPin,LOW);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
case 6:
digitalWrite(APin,LOW);
digitalWrite(BPin,HIGH);
digitalWrite(CPin,LOW);
digitalWrite(DPin,LOW);
digitalWrite(EPin,LOW);
digitalWrite(FPin,LOW);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
case 7:
digitalWrite(APin,LOW);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,HIGH);
digitalWrite(EPin,HIGH);
digitalWrite(FPin,HIGH);
digitalWrite(GPin,HIGH);
digitalWrite(DPPin,HIGH);
break;
case 8:
digitalWrite(APin,LOW);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,LOW);
digitalWrite(EPin,LOW);
digitalWrite(FPin,LOW);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
case 9:
digitalWrite(APin,LOW);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,LOW);
digitalWrite(EPin,HIGH);
digitalWrite(FPin,LOW);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
}
}
switch (m) {
case 0:
digitalWrite(APin,LOW);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,LOW);
digitalWrite(EPin,LOW);
digitalWrite(FPin,LOW);
digitalWrite(GPin,HIGH);
digitalWrite(DPPin,HIGH);
break;
case 1:
digitalWrite(APin,HIGH);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,HIGH);
digitalWrite(EPin,HIGH);
digitalWrite(FPin,HIGH);
digitalWrite(GPin,HIGH);
digitalWrite(DPPin,HIGH);
break;
case 2:
digitalWrite(APin,LOW);
digitalWrite(BPin,LOW);
digitalWrite(CPin,HIGH);
digitalWrite(DPin,LOW);
digitalWrite(EPin,LOW);
digitalWrite(FPin,HIGH);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
case 3:
digitalWrite(APin,LOW);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,LOW);
digitalWrite(EPin,HIGH);
digitalWrite(FPin,HIGH);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
case 4:
digitalWrite(APin,HIGH);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,HIGH);
digitalWrite(EPin,HIGH);
digitalWrite(FPin,LOW);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
case 5:
digitalWrite(APin,LOW);
digitalWrite(BPin,HIGH);
digitalWrite(CPin,LOW);
digitalWrite(DPin,LOW);
digitalWrite(EPin,HIGH);
digitalWrite(FPin,LOW);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
case 6:
digitalWrite(APin,LOW);
digitalWrite(BPin,HIGH);
digitalWrite(CPin,LOW);
digitalWrite(DPin,LOW);
digitalWrite(EPin,LOW);
digitalWrite(FPin,LOW);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
case 7:
digitalWrite(APin,LOW);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,HIGH);
digitalWrite(EPin,HIGH);
digitalWrite(FPin,HIGH);
digitalWrite(GPin,HIGH);
digitalWrite(DPPin,HIGH);
break;
case 8:
digitalWrite(APin,LOW);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,LOW);
digitalWrite(EPin,LOW);
digitalWrite(FPin,LOW);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
case 9:
digitalWrite(APin,LOW);
digitalWrite(BPin,LOW);
digitalWrite(CPin,LOW);
digitalWrite(DPin,LOW);
digitalWrite(EPin,HIGH);
digitalWrite(FPin,LOW);
digitalWrite(GPin,LOW);
digitalWrite(DPPin,HIGH);
break;
}
}
void Show(int v){
void SMG(int m);
int g,s,b,q;
g=v%1000%100%10/1;
s=(v%1000)%100/10;
b=(v%1000)/100;
q=(v/1000);
{digitalWrite(GWPin,HIGH);
digitalWrite(SWPin,LOW);
digitalWrite(BWPin,LOW);
digitalWrite(QWPin,LOW);
SMG(g);}
delay(1);
{digitalWrite(GWPin,LOW);
digitalWrite(SWPin,HIGH);
digitalWrite(BWPin,LOW);
digitalWrite(QWPin,LOW);
SMG(s);}
delay(1);
{digitalWrite(GWPin,LOW);
digitalWrite(SWPin,LOW);
digitalWrite(BWPin,HIGH);
digitalWrite(QWPin,LOW);
SMG(b);}
delay(1);
{digitalWrite(GWPin,LOW);
digitalWrite(SWPin,LOW);
digitalWrite(BWPin,LOW);
digitalWrite(QWPin,HIGH);
SMG(q);}
delay(1);
}
void SMG(int m);
int g,s,b,q;
g=v%1000%100%10/1;
s=(v%1000)%100/10;
b=(v%1000)/100;
q=(v/1000);
{digitalWrite(GWPin,HIGH);
digitalWrite(SWPin,LOW);
digitalWrite(BWPin,LOW);
digitalWrite(QWPin,LOW);
SMG(g);}
delay(1);
{digitalWrite(GWPin,LOW);
digitalWrite(SWPin,HIGH);
digitalWrite(BWPin,LOW);
digitalWrite(QWPin,LOW);
SMG(s);}
delay(1);
{digitalWrite(GWPin,LOW);
digitalWrite(SWPin,LOW);
digitalWrite(BWPin,HIGH);
digitalWrite(QWPin,LOW);
SMG(b);}
delay(1);
{digitalWrite(GWPin,LOW);
digitalWrite(SWPin,LOW);
digitalWrite(BWPin,LOW);
digitalWrite(QWPin,HIGH);
SMG(q);}
delay(1);
}
发表评论 评论 (0 个评论)