INPUT
THE INPUTS ON THE ARDUINO READ VOLTAGE. ALL INPUTS NEED TO BE THOUGHT OF IN TERMS OF VOLTAGE DIFFERENTIALS. THE ANALOG INPUTS CONVERT VOLTAGE LEVELS TO A NUMERICAL VALUE.
PULL-UP (OR DOWN) RESISTOR
PUSH BUTTON WITH PULL-DOWN RESISTOR When the button isn t pressed, the voltage going to pin 7 is pulled down to 0 because it is connected, via the resistor, to ground. When the button is pressed, the resistance going to ground is higher than that going to the input pin so the full voltage is sent to the pin.
CONTROL AN LED WITH A BUTTON
TOGGLE AN LED WITH A BUTTON Only change the state of the LED when there is a change from LOW to HIGH on the button. The old_val variable holds the state of the button the last time through loop.
TOGGLE AN LED WITH A BUTTON + DEBOUNCING Only change the state of the LED when there is a change from LOW to HIGH on the button. The old_val variable holds the state of the button the last time through loop.
PUSH BUTTON WITH PULL-UP RESISTOR When the button isn t pressed, the voltage going to pin 7 is pulled up to Vin because it is connected, via the resistor, to Vin. When the button is pressed, the pin is connected directly to ground.
ANALOG INPUT
POTENTIOMETER
POTENTIOMETER WITH BLINKING LED 1 1 5 5 10 10 15 15 20 20 25 25 30 30 A A B B C C D D E E F F G G H H I I J J 13 12 11 10 9 8 7 6 5 4 3 2 L 5V A0 ANALOG IN AREF 1 GND TX RX RESET 3V3 A1 A2 A3 A4 A5 VIN GND GND DIGITAL (PWM= ) Arduino TM IOREF ICSP ICSP2 ON POWER 0 1 TX0 RX0 RESET
READ ANALOG VALUES AND BLINK LED analogread() gives values in a range from 0-1024.
POTENTIOMETER WITH PWM LED 1 1 5 5 10 10 15 15 20 20 25 25 30 30 A A B B C C D D E E F F G G H H I I J J 13 12 11 10 9 8 7 6 5 4 3 2 L 5V A0 ANALOG IN AREF 1 GND TX RX RESET 3V3 A1 A2 A3 A4 A5 VIN GND GND DIGITAL (PWM= ) Arduino TM IOREF ICSP ICSP2 ON POWER 0 1 TX0 RX0 RESET
READ ANALOG VALUES AND FADE LED analogread() gives values in a range from 0-1024. analogwrite() can only write values from 0-255. To account for this we divide the value received from analogread() by 4.
VOLTAGE DIVIDER
VOLTAGE DIVIDER The resistor closest to the input voltage (V in ) is called R 1, and the resistor closest to ground R 2. The voltage drop across R 2 is called V out, that s the divided voltage our circuit exists to make.
THE EQUATION
IF R2 AND R1 ARE EQUAL THEN THE OUTPUT VOLTAGE IS HALF THAT OF THE INPUT. IF R2 IS MUCH LARGER THAN R1 (AT LEAST AN ORDER OF MAGNITUDE) THEN THE OUTPUT VOLTAGE WILL BE VERY CLOSE TO THE INPUT. IF R2 IS MUCH SMALLER THAN R1 THEN OUTPUT VOLTAGE WILL BE TINY COMPARED TO THE INPUT.
PHOTOCELL WITH VOLTAGE DIVIDER
PHOTOCELL WITH VOLTAGE DIVIDER Light Level R 2 (Sensor) R 1 (Fixed) Ratio R 2 /(R 1 +R 2 ) V out Light 1kΩ 5.6kΩ 0.15 0.76 V Dim 7kΩ 5.6kΩ 0.56 2.78 V Dark 10kΩ 5.6kΩ 0.67 3.21 V
PHOTOCELL WITH VOLTAGE DIVIDER Light Level R 2 (Sensor) R 1 (Fixed) Ratio R 2 /(R 1 +R 2 ) V out Light 1kΩ 5.6kΩ 0.15 0.76 V Dim 7kΩ 5.6kΩ 0.56 2.78 V Dark 10kΩ 5.6kΩ 0.67 3.21 V What the input pin gets
VOLTAGE DIVIDER You can tune the output of the sensor by changing the value of R 1.
READ ANALOG INPUT VALUES
READ ANALOG VALUES AND CONTROL LED analogread() gives values in a range from 0-1024. analogwrite() can only write values from 0-255. To account for this we divide the value received from analogread() by 4.
PRESSURE SENSOR WITH VOLTAGE DIVIDER
PRESSURE SENSOR WITH VOLTAGE DIVIDER
READ ANALOG INPUT VALUES
READ ANALOG VALUES AND CONTROL LED analogread() gives values in a range from 0-1024. analogwrite() can only write values from 0-255. To account for this we divide the value received from analogread() by 4.