dincabogdan2005
Published

Arduino behaving like an NE555

A fun project!

IntermediateProtip607
Arduino behaving like an NE555

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Capacitor 100 µF
Capacitor 100 µF
it can be any other value
×1
Resistor 1k ohm
Resistor 1k ohm
it can be any other value
×2
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
LED (generic)
LED (generic)
×1

Story

Read more

Schematics

capture_YW2i6GAjTK.PNG

Code

Untitled file

C/C++
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);  
}

}

Credits

dincabogdan2005

dincabogdan2005

0 projects • 0 followers

Comments