element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Blog Arduino Input multiplexer
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: tabarus12
  • Date Created: 22 Feb 2013 5:27 PM Date Created
  • Views 1038 views
  • Likes 1 like
  • Comments 1 comment
Related
Recommended

Arduino Input multiplexer

tabarus12
tabarus12
22 Feb 2013

This is my latest arduino shield that I made to experiment.

 

It is based on the 74ls151 input multiplexer, you can add more to eatch input that you need turning it in to an 8 bit input.

 

Here are some pictured and a basic schematic and code to read it.

 

Note, the resistor stripe is connecting the inputs to ground for use with switches, remove them to have a true digital input.

 

Have fun using it its very usefull, I know I will.image

Attachments:
image
image
image
Digital_Input_Multiplexer.ino.zip
imageDigital input multiplexer.pdf
  • Sign in to reply
  • tabarus12
    tabarus12 over 12 years ago

    Here a corrected version of the multiplexer program.

     

    Ive added a correction to the array and a for routine to pront serial data to port. Enjoyimage

     

     

    #include<Streaming.h>

     

    int b0 = 8; //Declare bit 0 pin

    int b1 = 9; //Declare bit 1 pin

    int b2 = 10; //Declare bit 2 pin

    int d1 = 11; //Declare data pin 1

    int d2 = 12; //Declare data pin 2

     

    int data1[9] = {0,0,0,0,0,0,0,0}; //Declare data 1 array

    int data2[9] = {0,0,0,0,0,0,0,0}; //Declare data 2 array

    int a = 1; //Declare array position variable

     

    void setup() {

      pinMode(b0,OUTPUT); //Set bit cero pin to output

      pinMode(b1,OUTPUT); //Set bit one pin to output

      pinMode(b2,OUTPUT); //Set bit two pin to output

     

      pinMode(d1,INPUT); //Set data pin 1 to input

      pinMode(d2,INPUT); //Set data pin 2 to input

     

      Serial.begin(9600); //Start serial port transmition

    }

     

    void loop() {

      a=1; //Set array position to 1

     

      for(a=1; a<=9; a++) { //Encrease aray position

        Bin(); //Call for binary print run

        if(digitalRead(d1) == HIGH) { //On data pin 1 enable

          data1[a]=1; //Set data array 1 position value to 1

        }

        else { //On data pin 1 disabled

          data1[a]=0; //Set data 1 array 1 position value to 0

        }

        if(digitalRead(d2) == HIGH) { //On data pin 2 enable

          data2[a]=1; //Set data array 2 position to 1

        }

        else { //On data 2 pin disable

          data2[a]=0; //Set data aray 2 position to 1

        }

        delay(50); //Delat for slow IC

                  //Remove if using fast speed IC

      }

      a=1;

      Serial << "  Mux A   MuxB" << endl;

      for(a=1; a<=8; a++){

        Serial << data1[a];

      }

      a=1;

      Serial << " ";

      for(a=1; a<=8; a++) {

        Serial << data2[a];

      }

      a=1;

      Serial << endl;

      //Print data array 1 and 2 value to serial port

    }

     

    void Bin() { //Binary print routine

      switch (a) { //Select on array position

        case 1: //On first case

          digitalWrite(b0, LOW); //Set bin 0 pin to 0

          digitalWrite(b1, LOW); //Set bin 1 pin to 0

          digitalWrite(b2, LOW); //Set bin 2 pin to 0

          break; //Break case

        case 2: //On second case

          digitalWrite(b0, HIGH); //Set bin 0 pin to 1

          digitalWrite(b1, LOW); //Set bin 1 pin to 0

          digitalWrite(b2, LOW); //Set bin 2 pin to 0

          break; //Break case

        case 3: //On third case

          digitalWrite(b0, LOW); //Set bin 0 pin to 0

          digitalWrite(b1, HIGH); //Set bin 1 pin to 1

          digitalWrite(b2, LOW); //Set bin 2 pin to 0

          break; //Break case

        case 4: //On fourth case

          digitalWrite(b0, HIGH); //Set bin 0 pin to 1

          digitalWrite(b1, HIGH); //Set bin 1 pin to 1

          digitalWrite(b2, LOW); //Set bin 2 pin to 0

          break; //Break case

        case 5: //On fifth case

          digitalWrite(b0, LOW); //Set bin 0 pin to 0

          digitalWrite(b1, LOW); //Set bin 1 pin to 0

          digitalWrite(b2, HIGH); //Set bin 2 pin to 1

          break; //Break case

        case 6: //On sixth case

          digitalWrite(b0, HIGH); //Set bin 0 pin to 1

          digitalWrite(b1, LOW); //Set bin 1 pin to 0

          digitalWrite(b2, HIGH); //Set bin 2 pin to 1

          break; //Break case

        case 7: //On seventh case

          digitalWrite(b0, LOW); //Set bin 0 pin to 0

          digitalWrite(b1, HIGH); //Set bin 1 pin to 1

          digitalWrite(b2, HIGH); //Set bin 2 pin to 1

          break; //Break case

        case 8: //On eight case

          digitalWrite(b0, HIGH); //Set bin 0 pin to 1

          digitalWrite(b1, HIGH); //Set bin 1 pin to 1

          digitalWrite(b2, HIGH); //Set bin 2 pin to 1

          break; //Break case

      }

    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube