Analog Input through POT A potentiometer (variable resistor) is connected to analog pin 0 to an Arduino. Values presented to pin 0 will vary depending upon the resistance of the potentiometer. void setup() { Serial.begin(9600); } void loop() { Serial.println(analogRead(0));
Arduino-Analog Output-LED Analog Out put is defined as sending signals from one of the digital pins on the Aurduino board that range between two extremes: 0-255 Out of 13 Digital pins on Arduino board the following pins can be used to signal out Analog output: 3,5,6,9,10,11 These are the pins with PWM label next to them on the board
Analog Input-Application The variable resistor can be replaced with a sensor. For example, a photo resistor. Depending upon the light level at the photo resistor: Turn on a light Increase or decrease the brightness of an LED (or an LED array) Most sensors are simply variable resistors, but vary their resistance based on some physical characteristic. void setup() { pinMode(9, OUTPUT); } void loop() int lightLevel = analogRead(0); lightLevel = map(lightLevel, 0, 900, 0, 255); lightLevel = constrain(lightLevel, 0, 255); analogWrite(9, 255 - lightLevel);
Sensors Sensors can be both binary or a range. Usually, sensors that measure a range of values vary their resistance to reflect their detection. Arduinos can only sense voltages, not resistances. Sensors that only vary their resistances require a circuit called a voltage divider to provide the Arduino a voltage.
Common Sensors Dials on a radio are simply potentiometers Temperature Light Angle Switches did the user throw a switch or push a button? Accelerometer (measures motion and tilt) Infrared sensor & light Hall effect sensor and magnet Ball tilt sensor (for measuring orientation) Force
Sensors and Modules Gas Sensor Temp & Humidity Fingerprint Scanner Flex Sensor Shields aren't the only way to extend an Arduino board - you can hook sensors to it! These are some of the hundreds (if not thousands) available. Many of these are not made specifically for Arduino - some sensors, such as thermistors, you can get from Radio Shack and wire them in! Sensors can run as low as $0.95 (for a thermistor or light sensor) to $150 (Geiger counter sensor) Geiger Counter
Sensors Photoresistor, infared, force sensitive resistor, Hall effect, Piezo, tilt sensor..
Arduino Types Many different versions Leonardo Due Micro LilyPad Number of input/output channels Form factor Processor Leonardo Due Micro LilyPad Esplora Uno