/*
-------------------------------------------------------------
Using the Arduino's output pins to display individual
segments on a 7-segment display (SSD)!
-------------------------------------------------------------
SSD: Common Cathode
Resistors: 2 x 220 ohm resistors on top and bottom
middle pins, connect these to GND (-) rail
on the breadboard
-------------------------------------------------------------
Arduino Pins: Pin 1 to Segment A on SSD
Pin 2 to Segment B on SSD
Pin 3 to Segment C on SSD
Pin 4 to Segment D on SSD
Pin 5 to Segment E on SSD
Pin 6 to Segment F on SSD
Pin 7 to Segment G on SSD
Pin 8 to decimal point on SSD
5V to + rail on breadboard
GND to - rail on breadboard
-------------------------------------------------------------
Note: Run another wire from the bottom GND
(-) rail on the breadboard up to its
counterpart at the top for the
middle pin on the top of the SSD to
connect to through a resistor.
-------------------------------------------------------------
*/
// sets up the pins going from the Arduino to the SSG for
// use in the code later on!
const int a = 1; // segment A on SSD (pin 1)
const int b = 2;
const int c = 3;
const int d = 4; // segment D on SSD (pin 4)
const int e = 5;
const int f = 6;
const int g = 7; // segment G on SSD (pin 7)
const int p = 8; // decimal point on SSD (pin 8)
void DoesItWork () // are all connections working?
{
digitalWrite(a, HIGH);
delay(50);
digitalWrite(b, HIGH);
delay(50);
digitalWrite(c, HIGH);
delay(50);
digitalWrite(d, HIGH);
delay(50);
digitalWrite(e, HIGH);
delay(50);
digitalWrite(f, HIGH);
delay(50);
digitalWrite(g, HIGH);
delay(50);
digitalWrite(p, HIGH);
delay(50);
}
void TurnMeOff () // turns all segments OFF
{
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, LOW);
digitalWrite(p, LOW);
delay(50);
}
void setup () // all pins set to OUTPUT mode
{
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode(p, OUTPUT);
}
void loop ()
{
DoesItWork ();
TurnMeOff ();
}