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
| 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 | ||||
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; // 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
You might also be interested in:
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.