Monday, 8 February 2010

7 segment display code 1

This is the code i created over a weekend,

The code is programmed in order for the 7 Led's to form a 7 segment display and run through the numbers 0 - 9 and on to a - z. This is an automatic program where the is a 2 second delay on each number/letter. This is not how the final program is going to be but it has helped a lot for me to learn how to work with the program.

int ledPina = 2;// LED connected to digital pin 2

int ledPinb = 3;// LED connected to digital pin 3

int ledPinc = 4;// LED connected to digital pin 4

int ledPind = 5;// LED connected to digital pin 5

int ledPine = 6;// LED connected to digital pin 6

int ledPinf = 7;// LED connected to digital pin 7

int ledPing = 8;// LED connected to digital pin 8

// The setup() method runs once, when the sketch starts

void setup() {

// initialize the digital pin as an output:

pinMode(ledPina, OUTPUT);

pinMode(ledPinb, OUTPUT);

pinMode(ledPinc, OUTPUT);

pinMode(ledPind, OUTPUT);

pinMode(ledPine, OUTPUT);

pinMode(ledPinf, OUTPUT);

pinMode(ledPing, OUTPUT);

}

// the loop() method runs over and over again,

// as long as the Arduino has power

void loop ()

{

digitalWrite(ledPina, HIGH); // set the LED on 0

digitalWrite(ledPinb, HIGH); // set the LED on

digitalWrite(ledPinc, HIGH); // set the LED on

digitalWrite(ledPind, HIGH); // set the LED on

digitalWrite(ledPine, HIGH); // set the LED on

digitalWrite(ledPinf, HIGH); // set the LED on

digitalWrite(ledPing, LOW); // set the LED off

delay(2000);

digitalWrite(ledPina, LOW); // set the LED off 1

digitalWrite(ledPind, LOW); // set the LED off

digitalWrite(ledPine, LOW); // set the LED off

digitalWrite(ledPinf, LOW); // set the LED off

delay(2000);

digitalWrite(ledPina, HIGH); // set the LED on 2

digitalWrite(ledPinc, LOW); // set the LED off

digitalWrite(ledPind, HIGH); // set the LED on

digitalWrite(ledPine, HIGH); // set the LED on

digitalWrite(ledPing, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPinc, HIGH); // set the LED on 3

digitalWrite(ledPine, LOW); // set the LED off

delay(2000);

digitalWrite(ledPina, LOW); // set the LED off 4

digitalWrite(ledPind, LOW); // set the LED off

digitalWrite(ledPine, LOW); // set the LED off

digitalWrite(ledPinf, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPina, HIGH); // set the LED on 5

digitalWrite(ledPinb, LOW); // set the LED off

digitalWrite(ledPind, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPine, HIGH); // set the LED on 6

delay(2000);

digitalWrite(ledPinb, HIGH); // set the LED on7

digitalWrite(ledPind, LOW); // set the LED off

digitalWrite(ledPine, LOW); // set the LED off

digitalWrite(ledPinf, LOW); // set the LED off

digitalWrite(ledPing, LOW); // set the LED off

delay(2000);

digitalWrite(ledPind, HIGH); // set the LED on 8

digitalWrite(ledPine, HIGH); // set the LED on

digitalWrite(ledPinf, HIGH); // set the LED on

digitalWrite(ledPing, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPind, LOW); // set the LED off 9

digitalWrite(ledPine, LOW); // set the LED off

delay(2000);

digitalWrite(ledPine, HIGH); // set the LED on a

delay(2000);

digitalWrite(ledPina, LOW); // set the LED on b

digitalWrite(ledPinb, LOW); // set the LED on

digitalWrite(ledPind, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPina, HIGH); // set the LED on c

digitalWrite(ledPinc, LOW); // set the LED on

digitalWrite(ledPing, LOW); // set the LED on

delay(2000);

digitalWrite(ledPina, LOW); // set the LED on d

digitalWrite(ledPinb, HIGH); // set the LED on

digitalWrite(ledPinc, HIGH); // set the LED on

digitalWrite(ledPinf, LOW); // set the LED on

digitalWrite(ledPing, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPina, HIGH); // set the LED on e

digitalWrite(ledPinb, LOW); // set the LED on

digitalWrite(ledPinc, LOW); // set the LED on

digitalWrite(ledPinf, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPind, LOW); // set the LED on f

delay(2000);

digitalWrite(ledPinb, HIGH); // set the LED on g

digitalWrite(ledPinc, HIGH); // set the LED on

digitalWrite(ledPind, HIGH); // set the LED on

digitalWrite(ledPine, LOW); // set the LED on

delay(2000);

digitalWrite(ledPina, LOW); // set the LED on h

digitalWrite(ledPind, LOW); // set the LED on

digitalWrite(ledPine, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPina, LOW); // set the LED on i

digitalWrite(ledPine, LOW); // set the LED on

digitalWrite(ledPinf, LOW); // set the LED on

digitalWrite(ledPing, LOW); // set the LED on

delay(2000);

digitalWrite(ledPind, HIGH); // set the LED on j

digitalWrite(ledPine, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPina, HIGH); // set the LED on k

digitalWrite(ledPinb, LOW); // set the LED on

digitalWrite(ledPind, LOW); // set the LED on

digitalWrite(ledPinf, HIGH); // set the LED on

digitalWrite(ledPing, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPina, LOW); // set the LED on l

digitalWrite(ledPinc, LOW); // set the LED on

digitalWrite(ledPind, HIGH); // set the LED on

digitalWrite(ledPinf, HIGH); // set the LED on

digitalWrite(ledPing, LOW); // set the LED on

delay(2000);

digitalWrite(ledPina, HIGH); // set the LED on m

digitalWrite(ledPing, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPina, LOW); // set the LED on n

digitalWrite(ledPinc, HIGH); // set the LED on

digitalWrite(ledPind, LOW); // set the LED on

digitalWrite(ledPinf, LOW); // set the LED on

delay(2000);

digitalWrite(ledPind, HIGH); // set the LED on o

delay(2000);

digitalWrite(ledPina, HIGH); // set the LED on p

digitalWrite(ledPinb, HIGH); // set the LED on

digitalWrite(ledPinc, LOW); // set the LED on

digitalWrite(ledPind, LOW); // set the LED on

digitalWrite(ledPinf, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPinc, HIGH); // set the LED on q

digitalWrite(ledPine, LOW); // set the LED on

delay(2000);

digitalWrite(ledPina, LOW); // set the LED on r

digitalWrite(ledPinb, LOW); // set the LED on

digitalWrite(ledPinc, LOW); // set the LED on

digitalWrite(ledPine, HIGH); // set the LED on

digitalWrite(ledPinf, LOW); // set the LED on

delay(2000);

digitalWrite(ledPina, HIGH); // set the LED on s

digitalWrite(ledPinc, HIGH); // set the LED on

digitalWrite(ledPind, HIGH); // set the LED on

digitalWrite(ledPine, LOW); // set the LED on

digitalWrite(ledPinf, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPina, LOW); // set the LED on t

digitalWrite(ledPinc, LOW); // set the LED on

digitalWrite(ledPine, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPinb, HIGH); // set the LED on u

digitalWrite(ledPinc, HIGH); // set the LED on

digitalWrite(ledPing, LOW); // set the LED on

delay(2000);

digitalWrite(ledPinb, LOW); // set the LED on v

digitalWrite(ledPinf, LOW); // set the LED on

delay(2000);

digitalWrite(ledPina, HIGH); // set the LED on w

digitalWrite(ledPinc, LOW); // set the LED on

digitalWrite(ledPinf, HIGH); // set the LED on

digitalWrite(ledPing, HIGH); // set the LED on

delay(2000);

digitalWrite(ledPina, LOW); // set the LED on x

digitalWrite(ledPinb, HIGH); // set the LED on

digitalWrite(ledPinc, HIGH); // set the LED on

digitalWrite(ledPind, LOW); // set the LED on

delay(2000);

digitalWrite(ledPind, HIGH); // set the LED on y

digitalWrite(ledPine, LOW); // set the LED on

delay(2000);

digitalWrite(ledPina, HIGH); // set the LED on z

digitalWrite(ledPinc, LOW); // set the LED on

digitalWrite(ledPine, HIGH); // set the LED on

digitalWrite(ledPinf, LOW); // set the LED on

delay(2000);

}

No comments:

Post a Comment