Tuesday, December 1, 2009

playing with the arduino

so i took the responsive architectures workshops offered here a couple of weeks back.  i bought a couple of arduinos and electronic brick starter kits.  i am in the process of developing an "insult machine" (more to come...) and found myself short of pins (pins can each control something, like a button, a switch, a potentiometer (the rotary dial), etc.).  so i went to toronto and bought something called a multiplexer ($2.80), which, using 5 pins from the arduino, allows you to control up to 16 pins (basically, you can do MORE with one arduino)
to use the multiplexer i must move from the safety of the electronic bricks to the wilds of the breadboard (what is a breadboard?). ($4.95 - $9.80 depending on the size, plus $0.35 per wire - i spent about $20 on wire)

the multiplexers details are: 16ch analog, #4607 from creatron
i got one working (after about two days, some help from Brandon DeHart and Phillip Beesley)
here is a diagram, a picture and the code to blink an LED on pin y8 (pin 23 on the multiplexer).

the only downside so far is that light doesn’t blink very brightly…any suggestions?

here is a diagram and a pic and the code:



/*
16 Channel Analog Extender for Arduino
*/

// Set Analog I/O pin to use for reading channel values from multiplexer.
int ComIOpin = 6;  // HEF4067BP(X)(ICpin-01)

// Set which pins tell the multiplexer which input to read from.
int DpinA0 = 10;  // HEF4067BP Address Input A0 (A)(ICpin-10)
int DpinA1 = 11;  // HEF4067BP Address Input A1 (B)(ICpin-11)
int DpinA2 = 12;  // HEF4067BP Address Input A2 (C)(ICpin-14)
int DpinA3 = 13;  // HEF4067BP Address Input A3 (D)(ICpin-13)

void setup() {

// Set the digital pins to outputs.
pinMode(DpinA0, OUTPUT);  // HEF4067BP Address Input A = pin10
pinMode(DpinA1, OUTPUT);  // HEF4067BP Address Input B = pin11
pinMode(DpinA2, OUTPUT);  // HEF4067BP Address Input C = pin12
pinMode(DpinA3, OUTPUT);  // HEF4067BP Address Input D = pin13
Serial.begin(9600); // Set Serial COM
}

void loop() {
digitalWrite(DpinA0, LOW);
digitalWrite(DpinA1, LOW);
digitalWrite(DpinA2, LOW);
digitalWrite(DpinA3, HIGH);
analogWrite(ComIOpin, HIGH);
delay(500);
digitalWrite(DpinA0, LOW);
digitalWrite(DpinA1, LOW);
digitalWrite(DpinA2, LOW);
digitalWrite(DpinA3, HIGH);
analogWrite(ComIOpin, LOW);
delay(500);
}

No comments:

Post a Comment