Digital Sensors
Digital sensors are (more) straight forward (than Analog)
No matter what the sensor there are only two states: On and Off
Signal is always either HIGH (On) or LOW (Off)
Voltage signal for HIGH will be 5V (more or less) on Arduino Uno. Other Arduinos could use different voltages!
Voltage signal for LOW will be 0V on most systems
Digital Input – Switch (single throw)
Image RemovedImage Added |
Image RemovedImage Added |
Digital Input – Switch (double throw)
Image RemovedImage Added NO = normally open C = common NC = normally closed. |
Image RemovedImage Added Note : The limit switch provided in EG1311 has a different order for NO, C, and NC. The connections in the picture above need to be adapted accordingly. |
Using Digital Input
Connect digital input to your Arduino using Pins # 0 – 13 (Avoid pins # 0 & 1 though as they are used for Serial later, and pin #11 and 13 as we are already using it)
Digital Input needs a pinMode function
pinMode (pinNumber, INPUT);
Make sure to use ALL CAPS for INPUT
int buttonState = digitalRead (pinNumber);
...
...
http://opensourcehardwarejunkies.com/tutorial-03-digitalread-and-serial-port-communication/ Anchor |
---|
if_digital | if_digitallanguage | cpp |
---|
theme | Confluence |
---|
|
pinMode (pinNumber, INPUT);
} |
|
int buttonState = digitalRead(2);
|
|
}]] ></ac:plain-text-body></ac:structured-macro></div></td><td><div class="content-wrapper"><p><ac:image ac:width="350"><ri:attachment ri:filename="image2020-1-21_21-21-50.png" /></ac:image></p></div><p><br /></p><p><br /></p><p>In Tinkercad, we just need to Start Simulation, and click on the switch to turn it on/off.</p></td></tr></tbody></table><h3>Screencast</h3><p><ac:structured-macro ac:name="widget" ac:schema-version="1" ac:macro-id="1d66f889-aaaf-4f76-9bae-caf55b4aaaf6"><ac:parameter ac:name="url"><ri:url ri:value="http://youtube.com/watch?v=nAjWYgvvML8" /></ac:parameter></ac:structured-macro></p><p><br /></p> | Image AddedIn Tinkercad, we just need to Start Simulation, and click on the switch to turn it on/off. |