Table of Contents |
---|
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)
Digital Input – Switch (double throw)
NO = normally open C = common NC = normally closed. | 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
- To get a digital reading:
int buttonState = digitalRead (pinNumber);
- Digital Input values are only HIGH (On) or LOW (Off)
http://opensourcehardwarejunkies.com/tutorial-03-digitalread-and-serial-port-communication/
Anchor | ||||
---|---|---|---|---|
|
C++ | Blocks | ||||||
---|---|---|---|---|---|---|---|
|