older library

Dependencies:   mbed

Committer:
DavidElmoRoss
Date:
Sat Sep 26 20:53:53 2020 +0000
Revision:
0:7116ad539a0c
older library;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DavidElmoRoss 0:7116ad539a0c 1 /*
DavidElmoRoss 0:7116ad539a0c 2 Title: 7 Segment Checker
DavidElmoRoss 0:7116ad539a0c 3 Author: David Ross
DavidElmoRoss 0:7116ad539a0c 4 Date: May 27th, 2016
DavidElmoRoss 0:7116ad539a0c 5 Description: This program will individually light up segments
DavidElmoRoss 0:7116ad539a0c 6 a, b, c, ... , h (dot) continually with a 0.5 second
DavidElmoRoss 0:7116ad539a0c 7 delay between each segment displayed
DavidElmoRoss 0:7116ad539a0c 8 */
DavidElmoRoss 0:7116ad539a0c 9
DavidElmoRoss 0:7116ad539a0c 10 #include "mbed.h"
DavidElmoRoss 0:7116ad539a0c 11
DavidElmoRoss 0:7116ad539a0c 12 // Declaration Section for seven_segs
DavidElmoRoss 0:7116ad539a0c 13
DavidElmoRoss 0:7116ad539a0c 14 BusOut seven_segs (D2, D3, D4, D6, D7, D9, D10, D11); // MSB=D11, LSB=D2
DavidElmoRoss 0:7116ad539a0c 15 int main(void)
DavidElmoRoss 0:7116ad539a0c 16 {
DavidElmoRoss 0:7116ad539a0c 17
DavidElmoRoss 0:7116ad539a0c 18 unsigned char value=0x80; // set value for CC Display
DavidElmoRoss 0:7116ad539a0c 19 unsigned char temp; // temp value for troubleshooting
DavidElmoRoss 0:7116ad539a0c 20 for(;;) // loop forever
DavidElmoRoss 0:7116ad539a0c 21 {
DavidElmoRoss 0:7116ad539a0c 22 temp= ~value; // invert value for CA display
DavidElmoRoss 0:7116ad539a0c 23 seven_segs= temp ; // send value to 7 segments
DavidElmoRoss 0:7116ad539a0c 24 wait_ms(500); // wait 0.5 seconds
DavidElmoRoss 0:7116ad539a0c 25 value=value >> 1; // shift to select next segment
DavidElmoRoss 0:7116ad539a0c 26 if(value < 1) // if value is 0
DavidElmoRoss 0:7116ad539a0c 27 {
DavidElmoRoss 0:7116ad539a0c 28 value=1; // then reset to 1
DavidElmoRoss 0:7116ad539a0c 29 do // reverses pattern
DavidElmoRoss 0:7116ad539a0c 30 {
DavidElmoRoss 0:7116ad539a0c 31 temp= ~value; // invert for CA display
DavidElmoRoss 0:7116ad539a0c 32 seven_segs= temp; // send value to 7 sements
DavidElmoRoss 0:7116ad539a0c 33 wait_ms(500); // wait 0.5 seconds
DavidElmoRoss 0:7116ad539a0c 34 value = value <<1; // shift to select next segment
DavidElmoRoss 0:7116ad539a0c 35 }while (value<0x80); // as long as < 0x80
DavidElmoRoss 0:7116ad539a0c 36 value=0x80; // then reset value to 0x80
DavidElmoRoss 0:7116ad539a0c 37 }
DavidElmoRoss 0:7116ad539a0c 38
DavidElmoRoss 0:7116ad539a0c 39 }
DavidElmoRoss 0:7116ad539a0c 40 }