rhoadley.net   music   research   software   blogs

aru    seminars    m&t    critski    focm1a    cmc    circuit bending    mic2b    sensor technology    comp 3    sonic art    major project
youtube    vimeo    facebook

Resources:    Bioacoustics    Jitter    MaxMSP    OSC    Physical    PD       CBHH    sTech    SuperCollider    C/Xcode

sTech Resources:     Home     Blog     Forum     Examples     Projects     Tasks     Tutorials

Sensor Technology Tasks

Multiplexing with the Arduino

Task 7 Name: Investigating sensors - Make your own sensor - Make your own arduino Set: w6i Due: Monday 19th December 2016 Weighting: assessable (10%) Courses: stech
Prev Task: Ping - Joining Code Next Task: Triggering and modulating events
Task Summary All sTech tasks


This is multiplexing



 * codeexample for useing a 4051 * analog multiplexer / demultiplexer
 * by david c. and tomek n.* for k3 / malms hsgskola
 * modifications by Richard Hoadley
 * rhoadley.net

int led = 13;    //just a led
int r0 = 0;      //value select pin at the 4051 (s0)
int r1 = 0;      //value select pin at the 4051 (s1)
int r2 = 0;      //value select pin at the 4051 (s2)
int row = 0;     // storing the bin code
int count = 0;    // just a count
int  bin [] = {000, 1, 10, 11, 100, 101, 110, 111};//bin = binSr, some times it is so easy
int val = 0;

void setup(){

  pinMode(2, OUTPUT);    // s0
  pinMode(3, OUTPUT);    // s1
  pinMode(4, OUTPUT);    // s2
  digitalWrite(led, HIGH); 

void loop () {

  for (count=0; count<=7; count++) {
    row = bin[count];      
    r0 = row & 0x01;
    r1 = (row>>1) & 0x01;
    r2 = (row>>2) & 0x01;
    digitalWrite(2, r0);
    digitalWrite(3, r1);
    digitalWrite(4, r2);    
    // Serial.println(bin[count]);

    if ( bin[count] == 0 )
        // Serial.println("true");
        val = analogRead(0);
        Serial.print("y0: ");
    if ( bin[count] == 11 )
        // Serial.println("true");
        val = analogRead(0);
        Serial.print("y3: ");
    delay (10);
  }  // end of for
} // end of loop

To Cover

  • Multiplexing and demultiplexing
  • Uses
  • Other uses (e.g. Teabox, audio interfaces, etc.)
  • Disadvantages


  • Using many more than the normal range of inputs and outputs from the Arduino, but not without some cost to responsiveness under some circumstances.

to top of page The Task

  • This is not a weighted task, but you're encouraged to complete it if only to increase your confidence and knowledge.

  • Clearly, I don't want you to submit your Arduinos. That means you need to submit some documentary evidence that you've completed your task. The most obvious way to do this is to submit some sort of video of your task working, as well as of the code running. If you can't do this, take photos.

  • Bear in mind that you'll get extra marks for added value, so try to adapt and make more interesting your files. Simply repeating what we've already done will get minimal marks. So try each patch out in various ways. For instance, even if the task just involves a blinking LED, try using patterns of colours and/or timings.

  • Zip or Stuff your patches, demos, photos, videos etc. into one file called your_student_number_"multiplex" (e.g. 0504335_multiplex.zip), include a readme with your name and student number and, if necessary, how to use or just open the patch, and submit the whole thing to WebCT.
  • Keep a copy of the task and submit to the i-Centre on Tuesday 10th May 2016

You might also be interested in:

The Projects

The projects and tasks are designed to help you through the various courses and materials that you'll have to deal with, and also to provide an active and practical element to what could otherwise become a rather dry and technical exercise. Tasks are small exercises - you may be asked to complete one or two per week. Projects are larger and carry a higher percentage of the mark. We will undertake two, three, four or more projects and tasks. The final project is usually an individual choice project, and will be worth significantly more than the others in terms of percentages in your portfolio. We will usually try to set aside a time to perform the projects in a public setting.