33 IR Emitter Basic Connections 0-1.es/33 +5V 100nF C E B NPN 2.2k٠K A IR (infrared) co��unication is a popular, inexpensive, and easy to use wireless co��unication technology. IR light is very similar to visible light, except that it has a slightly longer wavelength. This means IR is undetectable to the human eye, making it perfect for wireless co��unication. 104 J100 33٠Don't forget to connect all the ground wires together! E C B 2N2222 TSAL6200 A K ABC Basic Connections 2018.indd 101 23/11/2017 18:01
34 Basic Connections Constant-Current IR Emitter 0-1.es/34 +5V C E B NPN 3.3kΩ K A A K 2.7Ω Don't forget to connect all the ground wires together! E C B 2N2222 TSAL6100 A K 1N4148 ABC Basic Connections 2018.indd 102 23/11/2017 18:01
35 HD44780-Based LCD Basic Connections 0-1.es/35 6 5 4 3 2 D7 D6 D5 D4 1 E RS LCD CONTRAST ADJUSTMENT 10k٠RLIMIT +5V +5V Normally the LCD backlight is composed of LEDs in series. The total voltage drop across the LEDs is tipically 4.2V and the reco��ended current through the LEDs is 120mA. You should use a current limit resistor RLIMIT where: RLIMIT = (VBACKLIGHT-4.2)/0.12 Don't forget to connect all the ground wires together! Use only with LCDs with no current limiting resistor! Check the LCD documentation ABC Basic Connections 2018.indd 103 23/11/2017 18:01
35 Pinout HD44780-Based LCD 0-1.es/35 GND VDD VEE RSRW ED0D1D2D3D4D5D6D7 A K B E C NPN K A 2.2kΩ Don't forget to connect all the ground wires together! HIGH Light turns on when pin is set to E C B 2N2222 +5V RLIMIT Use only with LCDs with no current limiting resistor! Check the LCD documentation LCD Backlight Control ABC Basic Connections 2018.indd 104 23/11/2017 18:01
36 HD44780-Based LCD Via I2C Using the PCF8574 I/O Expander 0-1.es/36 +5V 100nF 104 J100 E RW RS D4 D5 D6 D7 1 2 SDA SCL 4.7kΩ C E B NPN K A 2.2kΩ Pull-up resistors Don't forget to connect all the ground wires together! E C B 2N2222 knM99353 TH50721 PCF8574P RLIMIT Use only with LCDs with no current limiting resistor! Check the LCD documentation ABC Basic Connections 2018.indd 105 23/11/2017 18:01
36 Pinout PCF8574 0-1.es/36 PCF8574P TH50721 knM99353 I2 C Pull-Up Resistors I2C is a popular co��unication protocol in embedded systems. When interfacing with the slave device a pull-up resistor is needed on each bi-directional line. This is just two wires, called SCL and SDA. SCL is the clock line that is used to synchronize all data transfers over the I2C bus. SDA is the data line. The SCL and SDA lines are connected to all devices on the I2C bus. There needs to be a third wire which is just the ground. Both SCL and SDA lines are “open drain” drivers. What this means is that the chip can drive its output low, but it cannot drive it high. For the line to be able to go high you must provide pull-up resistors to the 5V supply. There should be a resistor from the SCL line to the 5V line and another from the SDA line to the 5V line. You only need one set of pull-up resistors for the whole I2C bus, not for each device. GNDA0A1A2P0P1P2P3 VP4CC SCL SDA INT P7P6P5 PCF8574 ABC Basic Connections 2018.indd 106 23/11/2017 18:01
37 Nokia 5110 LCD Basic Connections 0-1.es/37 VCC GND SCE RST D/C DN SCLK LED 2 1 3 4 MOSI 5 SCK 6 LED SCLK DN D/C RST SCE VCC +3.3V GND 3.3kΩ 330Ω 1.8kΩ HELLO WORLD! 100nF 104 J100 Don't forget to connect all the ground wires together! ABC Basic Connections 2018.indd 107 23/11/2017 18:01
38 OLED LCD Basic Connections 0-1.es/38 HELLO WORLD!VCC GND SCL SDA VCC SCL SDA GND 1 SCL 2 SDA +3.3V 100nF 104 J100 Don't forget to connect all the ground wires together! ABC Basic Connections 2018.indd 108 23/11/2017 18:01
39 UC1701 128x64 LCD Basic Connections 0-1.es/39 HELLO HELLO HELLO HELLO CS RESET SDA RS ROM LEDA VSS VDD SCLK _CS ROM_SCK ROM_OUT ROM_IN VDD +3.3V SCK SDA VSS 1 SCK 2 MOSI 3 CS CS 4 RST 5 RS LEDA Don't forget to connect all the ground wires together! ABC Basic Connections 2018.indd 109 23/11/2017 18:02
40 ST7032i LCD Basic Connections 0-1.es/40 CSCSCSCSCSCSCSCS VOUT CAPIN CAPIP VDD VSS SDA SCL RESET SCL 1 SDA 2 +3.3V 10kΩ +3.3V 1µF 1µF 105 J100 Don't forget to connect all the ground wires together! ABC Basic Connections 2018.indd 110 23/11/2017 18:02
41 DS Touchscreen Basic Connections 0-1.es/41 XY+ X+ Y10kΩ Analog signals 1 2 3 4 Don't forget to connect all the ground wires together! ABC Basic Connections 2018.indd 111 23/11/2017 18:02
42 Simple Touch Sensor Basic Connections 0-1.es/42 C E B NPN C E B NPN 100kΩ 10kΩ +5V This simpe touch sensor is based on a Darlington configuration of transistors. They behave like a single transistor with a very high current gain, making it sensitive enough to respond to the small current passing through your body when you touch the metallic plates, activating the circuit. Don't forget to connect all the ground wires together! E C B 2N2222 Pin goes when contacts are touched LOW ABC Basic Connections 2018.indd 112 23/11/2017 18:02
43 Pushbutton Basic Connections 0-1.es/43 +5V +5V Pushbuttons or switches connect two points in a circuit when you press them. If you don't use the pull-up or pull-down resistor, the input pin is “floating” and will randomly return either HIGH or LOW values. Don’t forget to connect all the ground wires together! LOW HIGH 10kΩ 10kΩ 1 2 1 2 Pin goes when button is pressed Pin goes when button is pressed Don't forget to connect all the ground wires together! ABC Basic Connections 2018.indd 113 23/11/2017 18:02
43 Pushbutton Test Code 0-1.es/43 int LEDPin = 13; int SWITCHPin = 4; int val; void setup() { pinMode(LEDPin,OUTPUT); pinMode(BUTTONPin,INPUT); } void loop() { val = digitalRead(SWITCHPin); if (val == LOW) { digitalWrite(LEDPin,HIGH); } if (val == HIGH) { digitalWrite(LEDPin,LOW); } } Read input value and store it in val Check if the button is pressed Turn LED on Check if the button is not pressed Turn LED off Initialize the pin as an OUTPUT Initialize the pin as an INPUT Assign variable LEDPin as pin 13 Assign variable SWITCHPin as pin 4 Variable for reading the pin status Using Internal Pull-Up Resistors Pin goes HIGH when button is pressed Don't forget to connect all the ground wires together! ABC Basic Connections 2018.indd 114 23/11/2017 18:02
44 Pushbutton to 12V Basic Connections 0-1.es/44 +12V 1k٠470٠104 J100 100nF 12V signals are often found in many electronic systems and appliances, as signal voltage swings of 12V are advantageous to increase noise i��unity. Electronic noise captured by the input wiring will be reduced by about 2/3 thanks to the resistor divider. Noise can be further reduced by the 100nF capacitor. Don't forget to connect all the ground wires together! Pin goes HIGH when button is pressed 2.2k٠when input is +24V ABC Basic Connections 2018.indd 115 23/11/2017 18:02
45 Toggle Switch Basic Connections 0-1.es/45 +5V +5V Analog signal Using One Analog Input 13 2 1 2 3 10kΩ 10kΩ 1 2 3 SPDT ON - ON SPTT/SPCO ON - OFF - ON 10kΩ 10kΩ 1 2 Pin goes HIGH when position is selected Pin goes HIGH when position is selected ABC Basic Connections 2018.indd 116 23/11/2017 18:02
46 Multiple Pushbuttons Basic Connections 0-1.es/46 +5V 1kΩ 1kΩ 1kΩ 1kΩ 1kΩ 1MΩ This circuit cannot handle simultaneous button presses. In order to do that, you could use resistors with values at 2x increments with respect to the previous one (e.g., 1kΩ, 2kΩ, 4kΩ, 8kΩ). Hence by checking the voltage value, you should be able to tell which buttons are pressed simultaneously. Analog signal ABC Basic Connections 2018.indd 117 23/11/2017 18:02
47 Rotary Encoder Using Internal Pull-Up Resistors How Rotary Encoders Work 0-1.es/47 A B COM 100nF 100nF 104 J100 1 2 1 0 1 1 0 1 0 0 1 0 0 1 0 1 0 0 1 Output A Output B Output B Output A Counterclockwise Clockwise 90º phase shift Interrupt pins 10kΩ ABC Basic Connections 2018.indd 118 23/11/2017 18:02
0-1.es/48 Output A Output B COM Inside a Rotary Encoder 104 J100 2 1 B A COM +5V 10kΩ 10kΩ 10kΩ 10kΩ 100nF 100nF Interrupt pin Interrupt pin 48 Rotary Encoder Basic Connections ABC Basic Connections 2018.indd 119 23/11/2017 18:02
0-1.es/49 +5V 100Ω 10kΩ Pin goes LOW when button is pressed Pin goes HIGH when button is pressed 100nF +5V 100Ω 10kΩ 100nF 104 J100 49 Simple Debouncing Circuit Basic Connections ABC Basic Connections 2018.indd 120 23/11/2017 18:02
50 Debouncing Theory 0-1.es/50 Contact bounce is a co��on problem associated with mechanical switches and relays. Switch and relay contacts are made up of spring metals which are forced to contact each other by an actuator. While they collide with each other there is a possibility of rebounding for some time before they make a stable contact. As a result of this effect there will be ON/OFF transitions generated as the contacts rapidly open and close. Contact bounce is an undesired behavior which generates multiple transitions for a single user input. Bouncing Switch bouncing in pull-up connection Switch not Bouncing pressed Switch not pressed GND Vcc t Bouncing Switch bouncing in pull-down connection Switch not Bouncing pressed Switch not pressed GND Vcc t Vout Vout Switch pressed Switch pressed ABC Basic Connections 2018.indd 121 23/11/2017 18:02
51 Debouncing Using the 74LS14 Schmitt Trigger Inverter 0-1.es/51 +5V 10kΩ 4.7kΩ 100nF 104 J100 +5V 100nF IC Connections The 74LS14 has 6 ports available: xA xY Pin goes when HIGH button is pressed LS14 9CAX0DK G4 GND1A1Y2A2Y3A3Y VCC 6A6Y5A5Y4A4Y 74LS14 ABC Basic Connections 2018.indd 122 23/11/2017 18:02
52 Rotary Encoder Debouncing 0-1.es/52 220Ω B A COM 220Ω 3.3kΩ 3.3kΩ +5V 1µF 6.3V 1µF 6.3V STEP 1 DIR 2 Using the 74LS14 & the 74LS74 D CK 5 6 1 4 3 74LS74 Interrupt pins Don't forget to connect all the ground wires together! +- 1µF 6.3V ABC Basic Connections 2018.indd 123 23/11/2017 18:02
52 74LS14 & 74LS74 0-1.es/52 74LS14 & 74LS74 Connections +5V 100nF +5V 100nF 104 J100 GND1A1Y2A2Y3A3Y VCC 6A6Y5A5Y4A4Y 74LS14 Pinout GNDCKQ1 D CLRPRQ1 VCC CLR DCKPRQ2Q2 CK CLR PR Q D Q CK PR CLR Q D Q 74LS74 CK CLR PR Q D Q CK PR CLR Q D Q LS14 9CAX0DK G4 LS74 9CAX0DK G4 ABC Basic Connections 2018.indd 124 23/11/2017 18:02
53 Keypad Basic Connections 0-1.es/53 1 2 5 4 7 A K A K A K 3 8 Interrupt pin Optional interrupt circuit 1N4148 6 ABC Basic Connections 2018.indd 125 23/11/2017 18:02
53 Keypad Pinout 0-1.es/53 1 ROW0 ROW1 ROW2 ROW3 COL0 COL1 COL2 7 3 1 5 2 7 6 4 Keypads are ubiquitous in many electronic appliances and are used as input devices. Note that computer and calculator keypads have a different key arrangement compared to telephones, locks or ATMs. ABC Basic Connections 2018.indd 126 23/11/2017 18:02
0-1.es/54 ROW0 ROW1 ROW2 ROW3 COL0 COL1 COL2 1 2 3 4 5 6 7 8 9 * 0 # ROW0 1 ROW1 2 ROW2 3 ROW3 4 1 4 7 *COL0 5 2 5 8 0COL1 6 3 6 9 #COL2 7 54 Membrane Keypad Pinout ABC Basic Connections 2018.indd 127 23/11/2017 18:02
0-1.es/54 1kΩ 1kΩ 1kΩ Analog signal 4.7kΩ 4.7kΩ 4.7kΩ Don't forget to connect all the ground wires together! ROW0 ROW1 ROW2 ROW3 COL0 COL1 COL2 +5V 54 Basic Connections Keypad With 1 Analog Pin ABC Basic Connections 2018.indd 128 23/11/2017 18:02
55 Thumbwheel Switch Basic Connections 0-1.es/55 +5V 1 2 3 4 1 1 2 2 1 1 2 4 8 2 8 4 1 4 4 Don't forget to connect all the ground wires together! 4x10kΩ 1 2 4 8 COM ABC Basic Connections 2018.indd 129 23/11/2017 18:02
56 Basic Connections Rotary Switch 0-1.es/56 3 2 1 4 4x10kΩ Rotary switches are switches that have fixed angular positions that click in place when the connection is established by rotating the shaft. You could build this circuit using just one analog pin as in the Multiple Pushbuttons sheet by replacing the pushbuttons in that circuit with a rotary switch. Don't forget to connect all the ground wires together! Pin goes HIGH when switch is connected +5V 1 COM 1 2 3 4 COM 1 2 3 4 COM 4 3 2 ABC Basic Connections 2018.indd 130 23/11/2017 18:02
57 PS/2 Keyboard Basic Connections 0-1.es/57 +5V DATA CLK 1 2 PS/2 is a simple synchronous serial protocol that uses only two wires for co��unication. Due to its simplicity, PS/2 keyboards are widely used with simple microcontroller boards. PS/2 keyboards can send the equivalent ASCII value of the key that has been pressed. Don't forget to connect all the ground wires together! Female connector Front view ABC Basic Connections 2018.indd 131 23/11/2017 18:02
58 Tri��er Basic Connections 0-1.es/58 Analog signal +5V Tri��ers are manually-adjustable, variable resistors with three terminals. Two terminals are connected to a resistive element and the third terminal is connected to an adjustable wiper. In this circuit, the position of the wiper determines the output voltage. 1 3 3 Resistive Strip Wiper 2 1 2 OUT Don't forget to connect all the ground wires together! ABC Basic Connections 2018.indd 132 23/11/2017 18:02
59 Photoresistor (LDR) Basic Connections 0-1.es/59 Photoresistors or photocells are light-controlled variable resistors. The resistance of a photoresistor decreases with increasing incident light intensity. Photoresistors can be applied in light-sensitive detector circuits and light-activated switching circuits. 10kΩ Analog signal +5V 1 2 1 2 Don't forget to connect all the ground wires together! ABC Basic Connections 2018.indd 133 23/11/2017 18:02
60 Phototransistor Basic Connections 0-1.es/60 +5V Phototransistors are light-sensitive transistors. Light reaches the the base–collector junction, where electrons are generated, and the current is amplified by the current gain. Phototransistors are faster than photoresistors and slower than photodiodes, but they are less sensitive to temperature. 2.2kΩ C E Analog signal Don't forget to connect all the ground wires together! E C BPW17N ABC Basic Connections 2018.indd 134 23/11/2017 18:02
Opto-isolated 61 Opto-Isolated DC Input Using the 4N25 Optocoupler 0-1.es/61 1kΩ 10kΩ +5V 4.7kΩ when input is +48V 2.2kΩ when input is +24V +12V Pin goes LOW when voltage is present at the input pin X4N25 449GG 4N25 A B K C NC E Do not connect the opto-isolated ground to the circuit ground ABC Basic Connections 2018.indd 135 23/11/2017 18:02
Opto-isolated 62 Opto-Isolated AC Input Using the 4N25 Optocoupler 0-1.es/62 1kΩ 10kΩ +5V 1N4007 A K 12V 4.7kΩ when input is 48V 2.2kΩ when input is 24V Pin goes LOW when voltage is present at the input pin X4N25 449GG 4N25 A B K C NC E Do not connect the opto-isolated ground to the circuit ground ABC Basic Connections 2018.indd 136 23/11/2017 18:02
63 SPST CMOS Analog Switch Using the 4066 Quad Bilateral Switch 0-1.es/63 +5V 100nF 104 J100 1 SW2 2 SW3 SW1 3 SW4 4 Maximum 10mA per I/O pin Switch is closed when pin is set to HIGH 4066 VCC A1 A4 X4 Y4 X3 GND Y3 A3 X2 Y1 X1 Y2 A2 Don't forget to connect all the ground wires together! Un60729E L7C9R203 74HC4066D NXP ABC Basic Connections 2018.indd 137 23/11/2017 18:02
64 AC Current Sensor Basic Connections 0-1.es/64 These non-invasive current sensing probes are an affordable solution for measuring high AC current. They are also called CT (current transformer) sensors because they act like current transformers, delivering a fraction of the current measured through magnetic induction. +5V A B 10µF 16V A B 100kΩ 22Ω 100kΩ Sensor Analog signal Don't forget to connect all the ground wires together! +- 10µF 16V ABC Basic Connections 2018.indd 138 23/11/2017 18:02
0-1.es/65 Analog signal Sensor The LM35 is an analog, precision temperature sensor. This circuit allows for a measuring range of 2°C to +150°C (35.6°F to +302°F) with a temperature accuracy of ±0.5°C (0.9°F). The output of the sensor is linear with respect to the measured temperature, increasing its output voltage by 10mV per degree Celsius. 100kΩ VS GND VOUT +5V Don't forget to connect all the ground wires together! The LM34 is the native Fahrenheit version of the LM35, although both work similarly VCC GND Out LM34/LM35 65 LM34/LM35 Temperature Sensor Basic Connections ABC Basic Connections 2018.indd 139 23/11/2017 18:02
0-1.es/66 This circuit allows the LM35 to achieve its full potential, allowing for a temperature measuring range of −55°C to +150°C (-67°F to +302°F). The voltage is measured between both analog signal outputs, so you need to read the values with your microcontroller and obtain the absolute value of the difference. Analog signals Sensor 18kΩ +5V K A 1 2 VS GND VOUT Don't forget to connect all the ground wires together! VCC GND Out LM34/LM35 1N4148 66 LM34/LM35 Temperature Sensor Full Range ABC Basic Connections 2018.indd 140 23/11/2017 18:02
67 TMP36 Temperature Sensor Basic Connections 0-1.es/67 Analog signal Sensor The TMP36 is an analog temperature sensor with a measuring range of −40°C to +125°C (-40°F to +257°F). It has a temperature accuracy of ±2°C and it is very linear. +5V 100nF 104 J100 VCC GND Out Don't forget to connect all the ground wires together! VCC GND Out TMP36 ABC Basic Connections 2018.indd 141 23/11/2017 18:02
68 MCP9700 Temperature Sensor Basic Connections 0-1.es/68 The MCP9700 is an analog temperature sensor with a measuring range of −40°C to +125°C (-40°F to +257°F). It has a temperature accuracy of ±2°C and it is very linear. Analog signal Sensor +5V 100nF 104 J100 100nF VCC GND Out Don't forget to connect all the ground wires together! MCP9700 VCC GND Out ABC Basic Connections 2018.indd 142 23/11/2017 18:02
69 LM335 Temperature Sensor Basic Connections 0-1.es/69 Analog signal Sensor The LM335 is a digital, linear, precision temperature sensor. It has a temperature measuring range of −55°C to +150°C (-67°F to +302°F) with an accuracy of 1°C (1.8°F). The LM335 measures temperature in Kelvin, so you will need to subtract 273 from your measurement to obtain the temperature in Celsius. 2.2kΩ +5V - + ADJ CALIBRATION 10kΩ Don't forget to connect all the ground wires together! Optional calibration circuit (VOUT � 2.982V at 25ºC (77ºF)) LM335 ADJ - + ABC Basic Connections 2018.indd 143 23/11/2017 18:02
70 Thermocouple Using the LM358 Op-Amp 0-1.es/70 CALIBRATION 100kΩ 100nF +5V 104 J100 270kΩ 1kΩ Analog signal Check wiring color codes online Don't forget to connect all the ground wires together! LM358P 112DVSH VDD OUT2 IN-2 IN+2 IN+1 IN-1 OUT1 GND LM358 ABC Basic Connections 2018.indd 144 23/11/2017 18:02
71 DHT11 Temp. & Humidity Sensor Basic Connections 0-1.es/71 The DHT11 is a digital, low cost, medium precision humidity and temperature sensor. Its measuring ranges are 20 to 90% (±5%) for relative humidity and 0°C to 50°C (±2°C) (32°F to 122°F (±3.6°F)) for temperature. 100nF 104 J100 VCC OUT NC GND Sensor4.7kΩ VCC GND OUT Don't forget to connect all the ground wires together! +5V ABC Basic Connections 2018.indd 145 23/11/2017 18:02
72 DHT22 Temp. & Humidity Sensor Basic Connections 0-1.es/72 The DHT22 (also called AM2302) is a digital temperature and humidity sensor very similar to the DHT11, except it offers higher-precision readings. Its measuring ranges are 0 to 90% (±2%) for relative humidity and -40°C to 80°C (±0.5°C) (-40°F to 176°F (±0.9°F)) for temperature. 100nF 104 J100 Sensor4.7kΩ VCC OUT NC GND VCC GND OUT Don't forget to connect all the ground wires together! +5V ABC Basic Connections 2018.indd 146 23/11/2017 18:02
73 DHT11/DHT22 2-Wire Connection Basic Connections 0-1.es/73 BAT85 K A This 2-wire connection circuit allows for reliable measurements over long distances. Twisted pair cables like UTP CAT5, used in computer networks such as Ethernet, are affordable and ubiquitous. VCC GND OUT 47µF 16V VCC OUT NC GND +5V 1kΩ Sensor Max cable lenght 300m (1000ft) UTP CAT5 cable reco��ended +- 47µF 16V ABC Basic Connections 2018.indd 147 23/11/2017 18:02
74 DS18B20 Temperature Sensor Basic Connections 0-1.es/74 4.7kΩ VDD GND DQ VDD GND DQ VDD GND DQ Sensor Sensor Sensor 100nF 104 J100 +5V VDD GND VDD GND DQ VDD GND DQ Sensor Sensor The DS18B20 is a digital, precision temperature sensor with a measuring range of −55°C to +150°C (±0.5°C) (-67°F to +257°F (±0.9°F)). Its 1-wire interface requires only one port pin for co��unication, providing the temperature value with just a few lines of code and allowing multiple sensors to run in parallel. Don't forget to connect all the ground wires together! Max cable lenght 40m (130ft) UTP CAT5 cable reco��ended DS18B20 VCC GND DQ ABC Basic Connections 2018.indd 148 23/11/2017 18:02
75 NTC Thermistor Basic Connections 0-1.es/75 Thermistors (thermally-sensitive resistors) are a type of resistor whose resistance is dependent on temperature. Their temperature range is typically -55°C to 200°C (-67°F to 392°F). Thermistors are affordable, sensitive but not very linear. 10kΩ 10kΩ Analog signal +5V NTC 10D-7 Don't forget to connect all the ground wires together! 1ABC Basic Connections 2018.indd 149 23/11/2017 18:02
76 RTD Temperature Sensor Using a PT1000 Sensor 0-1.es/76 10kΩ 56kΩ 10kΩ LM324 56kΩ 220kΩ Analog signal +5V 100nF 104 J100 10kΩ 100kΩ THRESHOLD 10kΩ 100µF 16V PT1000 Don't forget to connect all the ground wires together! +- 16V 100µF ABC Basic Connections 2018.indd 150 23/11/2017 18:02