Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

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/

C++Blocks
void setup()
{
  pinMode (pinNumber, INPUT);
}

void loop()
{
  int buttonState = digitalRead(2);

  if(buttonState == HIGH)
  {  // do something

  }

  else
  {  // do something else

  }

}]] ></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>
  • No labels