Digital sensors are the sensors that gives 2 state (on/off, 5V/0V). You will connect them to digital Pins and set it as INPUT.
inside of a push button
How to connect push button: Pull Down Resister
http://elab-kh-berlin.de/elab/wp-content/uploads/2015/04/pulldown-107x300.jpg 107w, http://elab-kh-berlin.de/elab/wp-content/uploads/2015/04/pulldown-128x360.jpg 128w, http://elab-kh-berlin.de/elab/wp-content/uploads/2015/04/pulldown.jpg 1001w" sizes="(max-width: 364px) 100vw, 364px" />
Try the example sketch: File/ Examples/ Digital/ Basics/ DigitalReadSerial
If the above is done, add LED and control its state with Button. Use example sketch examples/Digital/button sketch. You can also try StateChangeDetection sketch as well. Compare the difference.
*pull up resistor should be 10k ohm or bigger
Analog sensors on the other hand, gives range. You connect this types of Analog sensors to Analog Input pins which is measuring the incoming voltage between 0V-5V*. Arduino converts this incoming voltage into the number between 0-1023.
*If you are operating your Arduino with 3.3V, such as Lilypad or Arduino Mini with Lipo Battery, the analog pis refers to the range of 0V-3.3V instead.
“A potentiometer, informally a pot, is a three-terminal resistor with a sliding contact that forms an adjustable voltage divider. If only two terminals are used, one end and the wiper, it acts as a variable resistor or rheostat.”
inside of a potentiometer
“A photoresistor or light-dependent resistor (LDR) or photocell is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity; in other words, it exhibits photoconductivity.”
How to connect analog sensors: Voltage Divider:
You can divide the voltage by using 2 resisters.
If you have 2 exactly same resistors, the voltage gets half in the middle, like the first diagram.
As the ratio between two resisters changes, the voltage you get in the middle (between the resisters) changes accordingly.
As the analog input pins are reading the voltage input changes, we need to change the voltage that goes into the analog pins by changing the resistance connected to the analog input pin. Potentiometer is acting as voltage divider, between left pin and middle pin as one resister, and the middle pin and right pin as another. As you turn the knob, the ratio of two resisters change, thus the voltage flowing into the middle pin changes.
or if this was connected on the breadboard, it will be something like this
Try example sketch: File/examples/basic/AnalogReadSerial
Open the serialMonitor and see which input number you receive.
Add LED on one of the digital Pins with PWM and try to control its intensity with different kinds of sensors.
The sensors we have…
Capacitive sensing is also an interesting technique of sensing.
“capacitive sensing is a technology, based on capacitive coupling, that takes human body capacitance as input. Capacitive sensors detect anything that is conductive or has a dielectric different from that of air.” (from Wikipedia)
The nice thing about the capacitive sensing is that you need only one connection to a sensor (electrode), and any conductive material can be made into a sensor. Also, the user does not have to touch the electrode. It can be covered with another types of materials.
There is a very nice library and tutorial on capacitive sensing with Arudino. Go to the following link and try it >> http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense
Firmata a generic protocol for communicating with microcontrollers like the Arduino from software on a host computer. (from Arduino Playground)
For example you can access the sensor data on Arduino from Processing or PureData using Firmata Library.]
Download the firmata library for Processing and try to read out the data from Arduino. You can then use this value to draw or to play music… however you like