Expanding Arduino Pin W - DEMUX IC 4051
Expanding Arduino Pin W - DEMUX IC 4051
Expanding Arduino Pin W - DEMUX IC 4051
[https://2.bp.blogspot.com
/-AXWMewM_Ohc/VzSZCc0mk9I/AAAAAAAACpI/yypMN8v-y-UVxAT-
jUSd1aTmxnTdywo3wCLcB/s1600/4051_gif.gif]
Bi-directional device. It allows you to expand the number of pins available for
input and output.
MUX: MUltipleXing is choosing from one of varios lines (one at a time) and
forwards its contents
down a single line .
[https://encrypted-tbn1.gstatic.com
/images?q=tbn:ANd9GcS4YOvGpCHReJVvDuWwaoEprNhIY9kYAAlcT-
7T9GfWZflmzOxhuA]
DE: DEmultiplexer is doing the reverse operation; a single input line is fowarded
to one of many output lines.
demultiplexer symbol
1 of 8 14/04/2023, 22:07
06 #arduSerie - Expanding Arduino's Pin w/ DEMUX IC 4051 !! | Jungl... http://jungletronics.blogspot.com/2016/05/06-arduserie-expanding-ardu...
[https://3.bp.blogspot.com/-5CVXlN41LME/VzPZ-Jb_J9I/AAAAAAAACoE
/3FL4_O_oAWwSTuBHGim9HOd1lErC27rewCLcB/s1600/DigRotarySwitch.jpg]
The control of this IC is simple to implement. In this tutorial we started a
collection of codes and ways of making the chip work well with arduino. The
concept is simple. follow the slides to quickly understand the workings of this
fabulous IC: CD4051!!!
Controller keeps under systematic scanning the s0, s1 and s2 pins from IC, as it
was a security camera; As soon as outside signal is sensing, physically selects
the appropriate channel and prepares the circuit to read/write from/to a route
door on/to outside signal, by setting/reading a variable control.
We will study four types of code that the community has used to interface with
the Arduino; watch the video and download the code [https://github.com/giljr
/Ardu_Serie] and study line by line:
In our analogy, the input controller (code loaded in arduino) monitors (ternary
operator) the camera and realizes the input of an element, and quickly connects
(digitalWrite ()) of the appropriate channel;
ready, the trail is open to the external signal we forward to our building. Now only
reads the information in the common gateway (return analogRead(common);-)
const byte common = A0; // where the multiplexer in/out port is connected
2 of 8 14/04/2023, 22:07
06 #arduSerie - Expanding Arduino's Pin w/ DEMUX IC 4051 !! | Jungl... http://jungletronics.blogspot.com/2016/05/06-arduserie-expanding-ardu...
void setup ()
Serial.begin (115200);
} // end of setup
} // end of readSensor
void loop ()
Serial.print (i);
delay (1000);
} // end of loop
3 of 8 14/04/2023, 22:07
06 #arduSerie - Expanding Arduino's Pin w/ DEMUX IC 4051 !! | Jungl... http://jungletronics.blogspot.com/2016/05/06-arduserie-expanding-ardu...
WRITEPIN));
Realize you as the code is clean. Congratulations to ajfisher git
[https://github.com/ajfisher/arduino-analog-multiplexer] and thanks for masterpiece
code !
#include "analogmuxdemux.h"
analog signal
#define NO_PINS 8 // how many output pins are you going to use on the DeMux?
// set up the DeMux ready to be used. Watch the order of S0, S1 and S2.
void setup() {
pinMode(WRITEPIN, OUTPUT);
delay(1);
void loop() {
// go through each pin in turn and then just light it up like a dimmer
admux.SelectPin(pinno); // choose the pin you want to send signal to off the
DeMux
delay(1);
pin
delay(1);
/*
4 of 8 14/04/2023, 22:07
06 #arduSerie - Expanding Arduino's Pin w/ DEMUX IC 4051 !! | Jungl... http://jungletronics.blogspot.com/2016/05/06-arduserie-expanding-ardu...
edited by Ross R.
*/
void setup() {
pinMode(4, OUTPUT); // s0
pinMode(5, OUTPUT); // s1
pinMode(6, OUTPUT); // s2
void loop () {
r0 = bitRead(count, 0); // use this with arduino 0013 (and newer versions)
r1 = bitRead(count, 1); // use this with arduino 0013 (and newer versions)
r2 = bitRead(count, 2); // use this with arduino 0013 (and newer versions)
digitalWrite(4, r0);
digitalWrite(5, r1);
digitalWrite(6, r2);
analogWrite(common, 255);
delay(100);
/*
5 of 8 14/04/2023, 22:07
06 #arduSerie - Expanding Arduino's Pin w/ DEMUX IC 4051 !! | Jungl... http://jungletronics.blogspot.com/2016/05/06-arduserie-expanding-ardu...
*/
int bin [] = {000, 1, 10, 11, 100, 101, 110, 111};//bin = binär, some times it is so
easy
void setup() {
pinMode(4, OUTPUT); // s0
pinMode(5, OUTPUT); // s1
pinMode(6, OUTPUT); // s2
// digitalWrite(led, HIGH);
Serial.begin(9600);
void loop () {
row = bin[count];
digitalWrite(4, r0);
digitalWrite(5, r1);
digitalWrite(6, r2);
delay(100);
row = bin[count];
digitalWrite(4, r0);
digitalWrite(5, r1);
digitalWrite(6, r2);
6 of 8 14/04/2023, 22:07
06 #arduSerie - Expanding Arduino's Pin w/ DEMUX IC 4051 !! | Jungl... http://jungletronics.blogspot.com/2016/05/06-arduserie-expanding-ardu...
delay(100);
The idea is to know the background components that will help us in a great
project! Let's step by step. Accumulating knowledge and technology !!! This time
4051 DEMUX !!! This will be the technology that drives us to the level of great
inventors, just playing and being happy with electronics !!!
Watch the video now!!! thank you for the privilege to have you here !!!
Notes:
(i) In the laboratory, inadvertently, on code 1, I changed the MSB and LSB
connections order, S0. S1 and S2; What we observe is that the distribution
between the pins began to switch to the pins 13, 1, 15, 2, 14, 5, 12, and 4; unlike
as in the datasheet [https://www.google.com.br/url?sa=t&rct=j&q=&esrc=s&
source=web&cd=14&cad=rja&uact=8&ved=0ahUKEwj9-
Pvb4tfMAhWGhZAKHc6VClMQFgh0MA0&url=http%3A%2F
%2Fwww.ti.com%2Fproduct%2FCD4051B&
usg=AFQjCNHzmumoWtgRDcL6PlH6vomaLN7CkA&sig2=vSxMNDuaBbTD9JXe7IVAxA]
that gives the sequence 13, 14, 15, 12, 1, 5, 2, and 4 (see below). Although this
was noticed after recording, I decided to keep as is and add this observation; the
code works, although in another sequence. If you do not approve, change the
sequence between pins 11,10 and 9 and ready to give the sequence according
to the datasheet; others codes, 2-4, are as datasheet says.
[https://www.google.com.br
/url?sa=t&rct=j&q=&esrc=s&source=web&cd=14&cad=rja&uact=8&ved=0ahUKEwj9-
Pvb4tfMAhWGhZAKHc6VClMQFgh0MA0&url=http%3A%2F
%2Fwww.ti.com%2Fproduct%2FCD4051B&
usg=AFQjCNHzmumoWtgRDcL6PlH6vomaLN7CkA&sig2=vSxMNDuaBbTD9JXe7IVAxA]
7 of 8 14/04/2023, 22:07
06 #arduSerie - Expanding Arduino's Pin w/ DEMUX IC 4051 !! | Jungl... http://jungletronics.blogspot.com/2016/05/06-arduserie-expanding-ardu...
Function Equivalent
digitalRead(A0) = 1 analogRead() if > 512
digitaWrite(A0, 0) = 0 analogWrite(A0, 0) = 0
digitalWrite(A0, 1) AnalogWrite(A0, 255)
works only on analog pins; it
analogRead(x) can take any x value from 0 >
1023
works on all analog* and
analogWrite(A0,x) PWM** pins; it can take any x
value from 0 > 255
*analog pins use ADC 10-bit (hence, 2^10 = 1024-1)
**PWM pins use Timer0 (8-bit pins 6 & 5)
Timer1 (16-bit pins 9 & 10) and Timer2 (8-bit pins 11 &
3) Arduino UNO
(iii) It is that if we call the mixed methods, digital / analog, Arduino API will not
work predictably;
that was the reason it did not work in my lab the code in this link [http://dawson-
station.blogspot.com.br/2010/01/mux-demux-cd4051-parlor-tricks.html] ...but that's
another story ...
Until next experience !!!
0 Adicionar um comentário
8 of 8 14/04/2023, 22:07