Introduction: NE555 With Arduino Uno R3
The NE555 Timer, a mixed circuit composed of analog and digital circuits, integrates analog and logical functions into an independent IC, thus tremendously expanding the applications of analog integrated circuits. It is widely used in various timers, pulse generators, and oscillators. In this experiment, the Arduino Uno board is used to test the frequencies of square waves generated by the 555 oscillating circuit and show them on Serial Monitor.
Step 1: Components
The 555 IC was originally used as a timer, hence the name 555 time base circuit. It is now widely used in various electronic products because of its reliability, convenience, and low price. The 555 is a complex hybrid circuit with dozens of components such as a divider, comparator, basic R-S trigger, discharge tube, and buffer. Its pins and their functions. Pin 1 (GND): the ground
Pin 2 (TRIGGER ): when the voltage at the pin reduces to 1/3 of the VCC (or the threshold defined by the control board), the output terminal sends out a High level
Pin 3 (OUTPUT): outputs High or Low, two states 0 and 1 decided by the input electrical level; maximum output current approx. 200mA at High
Pin 4 (RESET): when a Low level is received at the pin, the timer will be reset and the output will return to Low level; usually connected to positive pole or neglected
Pin 5 (CONTROL VOLTAGE): to control the threshold voltage of the chip (if it skips connection, by default, the threshold voltage is 1/3 VCC and 2/3 VCC)
Pin 6 (THRESHOLD): when the voltage at the pin increases to 2/3 VCC (or the threshold defined by the control board), the output terminal sends out a High level
Pin 7 (DISCHARGE): output synchronized with Pin 3, with the same logical level; but this pin does not output current, so pin 3 is the real High (or Low) when pin 7 is the virtual High (or Low); connected to the open collector (OC) inside to discharge the capacitor
Pin 8 (VCC): positive terminal for the NE555 timer IC, ranging +4.5V to +16V
The NE555 timer works under the monostable, astable and bistable modes. In this experiment, apply it under the astable mode, which means it works as an oscillator.
Step 3: The Schematic Diagram
Step 4: Procedures
Connect a resistor R1 between the VCC and the discharging pin DS, another resistor between pin DS and the trigger pin TR which is connected to the threshold pin TH and then to the capacitor C1. Connect the RET (pin 4) to GND, CV (pin 5）to another capacitor C2 and then to the ground.
The oscillator starts to shake once the circuit is power on. Upon the energizing, since the voltage at C1 cannot change abruptly, which means pin 2 is Low level initially, set the timer to 1, so pin 3 is High level. The capacitor C1 charges via R1 and R2, in a time span:
When the voltage at C1 reaches the threshold 2/3Vcc, the timer is reset and pin 3 is Low level. Then C1 discharges via R2 till 2/3Vcc, in a time span:
Then the capacitor is recharged and the output voltage flips again:
Duty cycle D=Tc/(Tc+Td)
Since a potentiometer is used for resistor, we can output square wave signals with different duty cycles by adjusting its resistance. But R1 is a 10K resistor and R2 is 0k-50k, so the range of the ideal duty cycle is 0.545%-100%. If you want another else, you need to change the resistance of R1 and R2.
Build the circuit.
Download the code from https://github.com/primerobotics/Arduino
Upload the sketch to the Arduino Uno board
Click the Upload icon to upload the code to the control board.
If "Done uploading" appears at
the bottom of the window, it means the sketch has been successfully uploaded.
You should now see the 7-segment display from 0 to 9 and A to F.
Step 5: Code
//After burning the program, open the serial monitor,you can see that if you rotate the potentiometer, the length of the pulse (in microsecond) displayed will change accordingly.
int ne555 = 7; //attach to the third pin of NE555
unsigned long duration1; //the variable to store the HIGH length of the pulse
unsigned long duration2; //the variable to store the LOW length of the pulse
float dc; //the variable to store the duty cycle
pinMode(ne555, INPUT); //set the ne555 as an input
Serial.begin(9600); // start serial port at 9600 bps:
duration1 = pulseIn(ne555, HIGH); //Reads a pulse on ne555
Serial.print("Duty cycle: ");
Serial.print(dc); //print the length of the pulse on the serial monitor
Serial.println(); //print an blank on serial monitor
delay(500); //wait for 500 microseconds