rhoadley.net   music   research   courses   software   blogs

ARU    Seminars    Comp&Imp    NMP    CMC2a    CBHH
Sensor Technology    Sonic Art    Major Project    MA Resources


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: Arduino and Multiplexing Set: w9i Due: Thursday 16th December 2010 Weighting: 0% Courses: stech
Prev Task: Arduino and Servos Next Task: Communicate Wirelessly
Task Summary All sTech tasks

Mulitplexing

This is multiplexing

Resources

Code


/*
 * 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;    // LED (not necessary)
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 = binary value
int val = 0;

void setup(){

  pinMode(2, OUTPUT);    // s0
  pinMode(3, OUTPUT);    // s1
  pinMode(4, OUTPUT);    // s2
  digitalWrite(led, HIGH); 
  Serial.begin(9600);
}

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: ");
        Serial.println(val);
      };
      
    if ( bin[count] == 11 )
      {
        // Serial.println("true");
        val = analogRead(0);
        Serial.print("y3: ");
        Serial.println(val);
      };
      
    delay (10);
  }  // end of for
  
} // end of loop


To Cover

Ramifications





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.

    Added Value
  • 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.
  • Keep a copy of the task and submit to the i-Centre on Thursday 15th December 2011

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.