DigitalIn Hello World

Fork of DigitalIn_HelloWorld_Mbed by Mbed

Use

The DigitalIn API is used to read a digital pin. The value will be either 0 or 1. Buttons and switches are some of the more common digital inputs.

API

API reference.

Import librarymbed

No documentation found.
Revision:
7:64e67ec4441e
Parent:
6:315942f167d7
Child:
8:ef3558374977
--- a/main.cpp	Fri Mar 27 21:05:43 2015 +0000
+++ b/main.cpp	Fri Mar 27 21:24:54 2015 +0000
@@ -20,14 +20,13 @@
 
 int main()
 {
-    // check mypin object is initialized and connected to a pin
-    int check = mypin.is_connected();  
-    if(check) {
+    // check mypin object is initialized and connected to a pin 
+    if(mypin.is_connected()) {
         printf("mypin is connected and initialized! \n\r");
     }
     
-    // Set resistance on line
-    mypin.mode(PullNone); // valid modes are PullUp, PullDown, PullNone, OpenDrain
+    // Optional: set mode as PullUp/PullDown/PullNone/OpenDrain
+    mypin.mode(PullNone); /
     
     // press the button and see the console / led change
     while(1) {