## Introduction: 555 Timer Calculator for RaspberryPi, Arduino, or a Linux PC

This instructable is a calculator to determine the resistor and capacitor values to use in common 555 timer circuits. I have included versions for the RaspberryPi and the Arduino with simple circuits to blink two LEDs like the 555 would. The version for a Linux PC only shows the printed values.

The Idea came from this comment in this instructable where I built a hardware emulator for a 555 using an Arduino.

One thing occurred to me: What about a version, on the Arduino, where the component types and values are simply programmed in software, and thus don't have to exist as solid objects. You select the type of circuit, enter the values of the R + C components, and use either an external pin or software trigger as the source signal.

Steps 1 and 2 are the program and circuit for the RaspberryPi, you will need:

• RaspberryPi - any model
• Pushbutton switch
• Red LED
• Green LED
• 2 resistors 470-560 Ohm
• Jumper wires or 22 gauge solid hookup wire *

* You can use male/female jumper wires but one of the Pi Cobblers listed on this page from Adafruit will make it a lot easier: http://www.adafruit.com/search?q=cobbler

.

Steps 3 and 4 are the program and circuit for the Arduino, you will need:

• Arduino - I use an Uno
• Pushbutton switch
• Red LED
• Green LED
• 2 resistors 470-560 Ohm
• Jumper wires or 22 gauge solid hookup wire

.

Step 5 is the program for a Linux PC, that is all you need.

Step 6 explains how to run the program.

## Step 1: RaspberryPi Circuit

Build the circuit as shown in the picture and the diagram.

The third picture shows a resistor soldered onto an LED. This is optional, but I found that having a bunch of these made up makes breadboarding a lot easier. Solder a resistor to the cathode lead of some LEDs. The cathode lead is the shorter negative (ground) lead.

## Step 2: RaspberryPi Program

This project uses the wiringPi libraries, written by Gordon Henderson, for programming the GPIO in C in a style similar to the Arduino IDE.

wiringPi must be installed.

wiringPi uses it's own pin numbering scheme. All pin numbers mentioned in the program or in the text are wiringPi numbers unless otherwise specified.

After installing wiringPi you can obtain a list showing the pin numbering for your specific model of RaspberryPi by opening a command terminal and typing: gpio readall

Compile it with this command:

gcc -o 555CalcPi -Wall -I/usr/local/include -L/usr/local/lib 555CalcPi.c -lwiringPi

Run it with the command: sudo ./555CalcPi

## Step 3: Arduino Circuit

Build the circuit as shown in the picture and the diagram.

The third picture shows a resistor soldered onto an LED. This is optional, but I found that having a bunch of these made up makes breadboarding a lot easier. Solder a resistor to the cathode lead of some LEDs. The cathode lead is the shorter negative (ground) lead.

## Step 4: Arduino Program

This is the code for the Arduino, pay special attention to the F() macro in the Serial.print statements. when printing a string the compiler creates an array variable to hold the string. In a program like this where there are a lot of strings to print the 2 K of RAM for holding variables will fill up very fast. The F() macro makes the compiler read the string from the 32 K flash memory instead of loading it into the RAM. There is a very brief mention of this in the Arduino documentation here, and a full explanation located here.

Open the serial monitor and set the baud rate to 115200.

## Step 5: Linux PC Program

This is the code for a Linux PC. It is the same as the code for the RaspberryPi but with the GPIO and wiringPi setup code removed.

Download the file and compile the code with the command: gcc -o 555CalcPC 555CalcPC.c

And run it with the command: ./555CalcPC

If you are not running Linux and you have a C compiler you can probably compile this code . The clrscr() function will need to be changed to the way you clear the screen.

## Step 6: Using the Program

The programs let you try out different resistors and capacitors in a simulated 555 timer circuit.

The first picture shows what it looks like in the Arduino serial monitor. The baud rate needs to be set at 115200.

On all versions of the program you will first be asked which circuit to run, then you will be prompted for the resistor and capacitor values. When the R/C values are complete it will display the timings these values will produce in a 555 timer circuit.

At this point the Linux PC program will display the results for twenty seconds, long enough for you to read the results, then return to the main menu.

The RaspberryPi and Arduino versions then wait for you to push the button on the breadboard.

The green LED indicates that the output pin of the 555 is high, and red indicates low.

.

The astable oscillator starts with both LEDs off and when the button is pressed the lights will blink like they would on a 555. Pressing the button again will end the simulation and return to the main menu. If the high time or the low time is greater than 30 seconds they will switch at 30 seconds. Any more than that will get boring. The second picture is a diagram of the circuit that is simulated.

.

The mono-stable simulation shown in the third picture starts with the red LED on indicating the the 555 output is low. When the button is pressed the green LED will light for the correct amount of time. A second press will re-run the simulation. The simulation can be ended at any time by holding down the button for one second.

Participated in the
Digital Life 101 Challenge

Participated in the
Raspberry Pi Contest 2016