用户工具

站点工具


创意diy:用arduino模拟ne5555

项目网站

int npn=12;
int out=6;
void setup() {
Serial.begin(9600);
pinMode(npn,OUTPUT);
pinMode(out,OUTPUT);
}
 
bool comp1,comp2;
void loop() {
int x=analogRead(A0);//reading the voltage at the treshold and trigger pins
int y=analogRead(A1);
float trig=x*5/1023;
float tres=y*5/1023;
Serial.print("trig=");
Serial.println(trig);
Serial.print("tres=");
Serial.println(tres);
if (trig>=5/3){//comparator1
  comp2=false;
}
else{
  comp2=true;
}
if (tres>=10/3){//comparator2
  comp1=true;
}
else{
  comp1=false;
}
if (comp1==true && comp2==false){//flip flop
digitalWrite(npn,HIGH);
digitalWrite(out,LOW);  
}
if (comp1==false && comp2==true){
digitalWrite(npn,LOW);
digitalWrite(out,HIGH);  
}
 
}


purge    随机主题   
创意diy/用arduino模拟ne5555.txt · 最后更改: 2021/02/28 23:10 (外部编辑) · 查看次数: 10480