How to control an output pin...and how to find out what the compiler name for the pin is.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
captaintim
Date:
Tue Aug 16 20:25:31 2016 +0000
Parent:
0:e3b48fea2164
Child:
2:afd0cb53867f
Child:
3:9affc00dfa25
Commit message:
Modified Controlling_GPIO_pinouts to demo sample program using DigitalOut command to test LED segments on 4-digits 7-segment LED display, using mbed LPC1768 and Lumex LDQ-N514R1 LED display

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Dec 20 04:27:14 2015 +0000
+++ b/main.cpp	Tue Aug 16 20:25:31 2016 +0000
@@ -1,21 +1,146 @@
 #include "mbed.h"
 
-/*comments: testing turning on and off of Pin 26 
+/*comments: testing turning on and off of Pins for 7-segment diode
 using https://developer.mbed.org/users/synvox/notebook/lpc1768-pinout-with-labelled-mbed-pins/ 
-by Nenad Milosevic as a guide to the complier name (P2_0) for pin 26 
+by Nenad Milosevic 
 verification: put the black lead of a multimeter on pin 1 (gnd)
 and put the red lead on pin 26, voltage varies between +3.28VDC and 0VDC */
 
+/*test program to learn how to write code for a 4 digit, 7-segment LED display LDQ-N524R1
+The schematic for this (COMMON CATHODE) display shows the following connections
+schematic located at http://www.lumex.com/ldq-n514ri (open Specs PDF for drawing)
+
+Pin Out wiring guide:(connect these mbed pins to display)
+
+CONTROL   DISPLAY Pin#  MBED Pin#
+----------------------------------
+Digit1          12         14
+Digit2          9          13
+Digit3          8          12
+Digit4          6          11
+DP              3          10
+A               11         21
+B               7          22
+C               4          23
+D               2          24  
+E               1          25 
+F               5          26
+G               5          27
+
+There is no blanking on this display, 
+you have to write a ONE to Gnd pin for specific digit to turn it off
+Program demonstrates use of DigitalOut to control segments of 7 segment display for 4 digit display LDQ-N514R1  
+Author: Cap'n Tim Johnson PE
+Retired Professor
+Wentworth Institude of Technology 
+Dept. Electrical Engineering and Technology
+Boston, MA
+*/
+
+
+DigitalOut myled(LED1);  //used to signal where in the program "thou art".
 
 int main() {
-int on = 1;
-int off = 0;
-int i = 5;
+//int on = 1;
+//int off = 0;
+int i = 2;  //wait time interval
+  
+//test of LED 7-segment diodes on 4 digit display
+//while(1){
+ DigitalOut (p14, 0); //Turn on digit1, Most Significant Digit
+ DigitalOut (p21, 1); 
+ DigitalOut (p22, 1); 
+ DigitalOut (p23, 1); 
+ DigitalOut (p24, 1); 
+ DigitalOut (p25, 1); 
+ DigitalOut (p26, 1); 
+ DigitalOut (p27, 1); 
+ DigitalOut (p10, 1); //decimal point
+ wait (i);
+ 
+ DigitalOut (p14, 1); //turn off digit1
+ DigitalOut (p13, 0); //turn on digit2
+ DigitalOut (p21, 1); 
+ DigitalOut (p22, 1); 
+ DigitalOut (p23, 1); 
+ DigitalOut (p24, 1); 
+ DigitalOut (p25, 1); 
+ DigitalOut (p26, 1); 
+ DigitalOut (p27, 1); 
+ DigitalOut (p10, 1); //decimal point
+ wait (i);
+ 
+ DigitalOut (p13, 1); //turn off digit2
+ DigitalOut (p12, 0); //turn on digit3
+ DigitalOut (p21, 1); 
+ DigitalOut (p22, 1); 
+ DigitalOut (p23, 1); 
+ DigitalOut (p24, 1); 
+ DigitalOut (p25, 1); 
+ DigitalOut (p26, 1); 
+ DigitalOut (p27, 1); 
+ DigitalOut (p10, 1); //decimal point
+ wait (i);
+ 
+ DigitalOut (p12, 1); //turn off digit3
+ DigitalOut (p11, 0); //turn on digit4, Least Significant Digit
+ DigitalOut (p21, 1); 
+ DigitalOut (p22, 1); 
+ DigitalOut (p23, 1); 
+ DigitalOut (p24, 1); 
+ DigitalOut (p25, 1); 
+ DigitalOut (p26, 1); 
+ DigitalOut (p27, 1); 
+ DigitalOut (p10, 1); //decimal point
+ wait (i);
+ DigitalOut (p11, 1); //Turn off digit4
+ //they are all off
+ wait (1);
 
-while(1){
- DigitalOut (P2_0, on); //pin 26
+ myled=1;   //Signals all are about to turn on
+ wait (1);
+
+ DigitalOut (p14, 0); //Turn them all on
+ DigitalOut (p13, 0);
+ DigitalOut (p12, 0);
+ DigitalOut (p11, 0);
+ wait (i);
+ 
+ DigitalOut (p14, 1); //Turn them all off
+ DigitalOut (p13, 1);
+ DigitalOut (p12, 1);
+ DigitalOut (p11, 1);
+ wait (1);
+ 
+ DigitalOut (p14, 0); //Turn them all on as zeros
+ DigitalOut (p13, 0);
+ DigitalOut (p12, 0);
+ DigitalOut (p11, 0);
+ DigitalOut (p27, 0);
  wait (i);
-  DigitalOut (P2_0, off);
+
+ DigitalOut (p14, 1); //Turn them all off
+ DigitalOut (p13, 1);
+ DigitalOut (p12, 1);
+ DigitalOut (p11, 1);
+ wait (1);
+
+DigitalOut (p14, 0); //Turn them all on as sevens
+ DigitalOut (p13, 0);
+ DigitalOut (p12, 0);
+ DigitalOut (p11, 0);
+ DigitalOut (p24, 0);
+ DigitalOut (p25, 0);
+ DigitalOut (p26, 0);
+ DigitalOut (p27, 0);
  wait (i);
-   }
+
+ DigitalOut (p14, 1); //Turn them all off
+ DigitalOut (p13, 1);
+ DigitalOut (p12, 1);
+ DigitalOut (p11, 1);
+ wait (1);
+ 
+ myled=0;      //end of program signal
+ 
 }   
\ No newline at end of file