0% found this document useful (0 votes)
25 views

How To Get More Arduino Analog Inputs Post

This code configures the digital pins 8, 9, and 10 of an Arduino as outputs to control the select pins of a 4051 multiplexer. It then sets the select pins to different combinations in a loop to read the 8 analog input channels one by one from the 4051 into analog pin 0 of the Arduino, printing the results to the serial monitor.

Uploaded by

chivas1111
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

How To Get More Arduino Analog Inputs Post

This code configures the digital pins 8, 9, and 10 of an Arduino as outputs to control the select pins of a 4051 multiplexer. It then sets the select pins to different combinations in a loop to read the 8 analog input channels one by one from the 4051 into analog pin 0 of the Arduino, printing the results to the serial monitor.

Uploaded by

chivas1111
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

void setup()

//4051 digital control pins

pinMode(8, OUTPUT); // s0

pinMode(9, OUTPUT); // s1

pinMode(10, OUTPUT); // s2

Serial.begin(9600);

void loop()

//Read Value of 4051 analog-in 0 by setting the values of s0,s1 and s2

digitalWrite(8, LOW);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

delay(10); //not sure if this delay is strictly necessary

int readInZero = analogRead(0); // read the input pin

Serial.print(readInZero); //use the result

//repeat to read other pins (in this case analog in 2)

digitalWrite(8, LOW);

digitalWrite(9, HIGH);

digitalWrite(10, LOW);

delay(10);

int readInTwo= analogRead(0);

Serial.print(readInTwo);

//etc. for the other 6 4051 analog inputs

You might also like