Dependencies:   mbed

Fork of analogRead by Charles Tritt

Files at this revision

API Documentation at this revision

Comitter:
CSTritt
Date:
Wed Oct 11 02:29:09 2017 +0000
Parent:
2:e0faf9e57796
Commit message:
Initial version of the program used for pull-up and pull-down testing.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r e0faf9e57796 -r 8b392116b2f9 main.cpp
--- a/main.cpp	Mon Mar 27 14:20:32 2017 +0000
+++ b/main.cpp	Wed Oct 11 02:29:09 2017 +0000
@@ -1,10 +1,11 @@
 /*
-    Project: analogRead
+    Project: PullTest
     File: main.cpp
     
-    Reads from analog input, streams ASCII text to std serial using printf and
-    lights onboard LED. Also demonstrates use of floating point literal suffix
-    toeliminate warning and int constants for HIGH and LOW.
+    For exploring pull up, pull down and pull none behavior of F446RE boards. 
+    Makes D2-4 pull-up, D5-7 pull-down, and D8-10 pull-none. Test currents to 
+    power and ground to determine internal resistance. D11 used to check 
+    default operation (should be PullNone)
     
     Written by: Dr. C. S. Tritt
     Created: 3/27/17 (v. 1.1)
@@ -12,28 +13,25 @@
 */
 #include "mbed.h"
 
-const int HIGH = 1; // Optional, but makes code more readable.
-const int LOW = 0; // Optional, but makes code more readable.
- 
-AnalogIn analog_value(A0);
- 
-DigitalOut led(LED1);
+DigitalIn myD2(D2, PullDown); // D2-4 and D5-7 reversed.
+DigitalIn myD3(D3, PullDown);
+DigitalIn myD4(D4, PullDown);
+DigitalIn myD5(D5, PullUp);
+DigitalIn myD6(D6, PullUp);
+DigitalIn myD7(D7, PullUp);
+DigitalIn myD8(D8, PullNone);
+DigitalIn myD9(D9, PullNone);
+DigitalIn myD10(D10, PullNone);
+DigitalIn myD11(D11);
 
 int main() {
-    float value; // Value to be read and sent to serial port.
-    
-    printf("\nAnalogIn example\n");
+    printf("\nPull Tests\n");
     
     while(true) {
-        value = analog_value.read(); // Read the analog input value (0 to 1)
-        printf("Value = %f\n", value); // Send value as text via serial port.
-        if (value > 0.5f) { // Activate built-in LED. The f is optional.
-          led.write(HIGH);
-        }
-        else {
-          led.write(LOW);
-        }
-        printf("LED = %d\n", (int) led.read()); // Send LED state via serial. 
-        wait(0.25); // 250 ms
+        // Send D_In statuses. Casts to avoid non-POD type passed warnings.
+        printf("Ds = %d %d %d %d %d %d %d %d %d %d.\n",
+         (int) myD2, (int) myD3, (int) myD4, (int) myD5, (int) myD6, 
+         (int) myD7, (int) myD8, (int) myD9, (int) myD10, (int) myD11); 
+        wait(0.5); // 500 ms
     }
 }