Lesson 9 Ne555

Share for us


If you ask anyone in the know to rank the most commonly and widely used IC, the famous 555 time base IC would certainly be at the top of the list. The 555 – a mixed circuit composed of analog and digital circuits – integrates analogue and logical functions into an independent IC, and hence tremendously expands the application range of analog integrated circuits. The 555 is widely used in various timers, pulse generators, and oscillators.


– 1 * Raspberry Pi

– 1 * Breadboard

– 1 * NE555

– 2 * 104 ceramic capacitor

– 1 * Potentiometer (50KΩ)

– 1 * Resistor (10KΩ)

– 1 * USB cable

– Jumper wires


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.

555 chip pins are introduced as follows:

As shown in the picture, the 555 IC is dual in-line with the 8-pin package. Thus:

  • Pin 1 (GND): the ground;
  • Pin 2 (TRIGGER): the input of lower comparator;
  • Pin 3 (OUTPUT): having two states of 0 and 1 decided by the input electrical level;
  • Pin 4 (RESET): output low level when supplied a low one;
  • Pin 5 (CONTROL VOLTAGE): changing the upper and lower level trigger values;
  • Pin 6 (THRESHOLD): the input of upper comparator;
  • Pin 7 (DISCHARGE): having two states of suspension and ground connection also decided by input, and the output of the internal discharge tube;
  • Pin 8 (VCC): the power supply;

The schematic diagram

Experimental Procedures

Step 1: Build the circuit 

For C language users:

Step 2: Go to the folder of the code.

    cd /home/pi/SunFounder_Super_Kit_V3.0_for_Raspberry_Pi/C

Step 3: Compile

    make 09_ne555

Step 4: Run the executable file above.

    sudo ./09_ne555

For Python users:

Step 2: Get into the folder of the code.

    cd /home/pi/SunFounder_Super_Kit_V3.0_for_Raspberry_Pi/Python

Step 3: Run

     sudo python 09_ne555.py

Now you can see the number of square waves printed. Spin the potentiometer and the value will decrease or increase. 

C Code

* Filename 		: ne555.c
* Description 	: Count the pluses procude by NE555.
* Author 		: Robot
* E-mail 		: support@sunfounder.com
* Website 		: www.sunfounder.com
* Update 		: Dream    <2016-07-26>
* Detail		: <update details>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <wiringPi.h>

#define  Pin0  0

static volatile int globalCounter = 0 ;

void exInt0_ISR(void)  //GPIO0 interrupt service routine 

int main (void)
  if(wiringPiSetup() < 0){
  	fprintf(stderr, "Unable to setup wiringPi:%s\n",strerror(errno));
	return 1;

	printf("|                  Ne555               |\n");
	printf("|    ------------------------------    |\n");
	printf("| Output pin of ne555 connect to gpio0;|\n");
	printf("|                                      |\n");
	printf("|  Count the pluses procude by NE555.  |\n");
	printf("|                                      |\n");
	printf("|                            SunFounder|\n");

  wiringPiISR(Pin0, INT_EDGE_FALLING, &exInt0_ISR);

	printf("Current pluse number is : %d\n", globalCounter);

  return 0;

Python Code

#!/usr/bin/env python

import RPi.GPIO as GPIO
import time

# ne555 pin3 connect to BCM GPIO17
SigPin = 17    # BCM 17

g_count = 0

def print_msg():
	print ("========================================");
	print ("|                  Ne555               |");
	print ("|    ------------------------------    |");
	print ("| Output pin of ne555 connect to gpio0;|");
	print ("|                                      |");
	print ("|  Count the pluses procude by NE555.  |");
	print ("|                                      |");
	print ("|                            SunFounder|");
	print ("========================================\n");
	print 'Program is running...'
	print 'Please press Ctrl+C to end the program...'
	raw_input ("Press Enter to begin\n")

def count(ev=None):
	global g_count
	g_count += 1

def setup():
	GPIO.setmode(GPIO.BCM)       # Numbers GPIOs by physical location
	GPIO.setup(SigPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)    # Set Pin's mode is input, and pull up to high level(3.3V)
	GPIO.add_event_detect(SigPin, GPIO.RISING, callback=count) # wait for rasing

def main():
	while True:
		print 'g_count = %d' % g_count

def destroy():
	GPIO.cleanup()    # Release resource

if __name__ == '__main__':     # Program start from here
	except KeyboardInterrupt:  # When 'Ctrl+C' is pressed, the child program destroy() will be  executed.