Location: //CODE

Discussion: I FOUND OUR CODE ONLINEReported This is a featured thread

Showing 1 post

not_my_balls
I FOUND OUR CODE ONLINE
Nov 18 2007, 3:44 PM EST | Post edited: Nov 18 2007, 3:44 PM EST


arduino:

/* ReadMultiplexedSensorsAndSendMIDI
* ------------
*
* Reads 4 16 channel Multiplexers and sends the values
*
* Created 12 December 2005
* copyleft 2005 Stephen Williams <http://fluidforms.at> <http://algodes.com>
*
*/

#define CONTROLpin1 2
#define CONTROLpin2 3
#define CONTROLpin3 4
#define CONTROLpin4 5

// Variables:
char sensorValueToSend = 0; // Value of the sensor
int actualSensorValue = 0; // value from the analog input

// Some error chacking would be good here.
//If the values exceede 128 the will not fit in one byte.
void sendCommand(char command, char sensorID, char value) {
serialWrite(command);
serialWrite(sensorID);
serialWrite(value);
}


void setup() {
// set the states of the I/O pins:
pinMode(LEDpin, OUTPUT);
pinMode(CONTROLpin1, OUTPUT);
pinMode(CONTROLpin2, OUTPUT);
pinMode(CONTROLpin3, OUTPUT);
pinMode(CONTROLpin4, OUTPUT);

beginSerial(19200);
}


void loop() {
int i;
int j;
for (i=0; i <16; i++) {

// set control pins on the multiplexers
digitalWrite(CONTROLpin1, (i&15)>>3);//bit4
digitalWrite(CONTROLpin2, (i&7)>>2);//bit3
digitalWrite(CONTROLpin3, (i&3)>>1);//bit2
digitalWrite(CONTROLpin4, (i&1) );//bit1

// read the analogue inputs and send the values of the sensors.
for(j=0; j<4; j++){
actualSensorValue = analogRead(j);
// You will have to adjust this line so that can send the
// sensor value in one byte.
sensorValueToSend = actualSensorValue / 15;
sendCommand(0x90, i+16*j, sensorValueToSend);
}
// if you uncomment this line you can check the control pins
// of the multiplexers with your multimeter.
//delay(500);
}
}


Do you find this valuable?    
Keyword tags: code page

Sign in to be the first to reply.

Related Content

  (what's this?Related ContentThanks to keyword tags, links to related pages and threads are added to the bottom of your pages. Up to 15 links are shown, determined by matching tags and by how recently the content was updated; keeping the most current at the top. Share your feedback on Wetpaint Central.)