Go Down

Topic: enable missing pins? (Read 740 times) previous topic - next topic

qwerky

May 02, 2012, 05:16 am Last Edit: May 02, 2012, 09:19 am by qwerky Reason: 1
hello : )

I have just set up a shift register circuit on a breadboard to control a 7 segment display.  arduino pins : 8, 11 and 12 are in use only, and it works great.  i use max msp to control the arduino, which sends 8 bit (0-255) numbers to the arduino which converts this to serial  for the 595 shift registers.

The problem I am having, is that the sketch I am using appears to be created only to demonstrate the shift register concept,  therefore all the other ins and outs on the arduino are not available.

i am wondering if it is possible to add code to the sketch (below), so that all the other pins can be used on the arduino ,as well as the 3 pins assigned for the shift registers via serial?

here is a link to the breadboard and arduino sketch
http://little-scale.blogspot.co.uk/2008/01/three-595-shift-registers.html
and here is a link to the max msp patch:
http://little-scale.blogspot.co.uk/2008/01/talking-to-3-595s-via-maxmsp.html

thanks for your help on this : )

here is the arduino sketch:

Code: [Select]
//Pin connected to ST_CP of 74HC595

int latchPin = 8;

//Pin connected to SH_CP of 74HC595

int clockPin = 12;

////Pin connected to DS of 74HC595

int dataPin = 11;

byte data1;

byte data2;

byte data3;

void setup() {

Serial.begin(57600);

pinMode(latchPin, OUTPUT);

}

void loop() {

if(Serial.available() > 2) {

data1 = Serial.read();

data2 = Serial.read();

data3 = Serial.read();

digitalWrite(latchPin, 0);

shiftOut(dataPin, clockPin, data1);

shiftOut(dataPin, clockPin, data2);

shiftOut(dataPin, clockPin, data3);

digitalWrite(latchPin, 1);

}

}

void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {

int i=0;

int pinState;

pinMode(myClockPin, OUTPUT);

pinMode(myDataPin, OUTPUT);

digitalWrite(myDataPin, 0);

digitalWrite(myClockPin, 0);

for (i=7; i>=0; i--) {

digitalWrite(myClockPin, 0);

if ( myDataOut & (1<<i) ) {

pinState= 1;

}

else {

pinState= 0;

}

digitalWrite(myDataPin, pinState);

digitalWrite(myClockPin, 1);

digitalWrite(myDataPin, 0);

}

digitalWrite(myClockPin, 0);

}


AWOL

Yes, of course you can.
Just set the correct pinMode in "setup", and away you go.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

qwerky

hey, thank you HAL. : )

I wasn't sure i was making sense.

do you know of any code anywhere that i could add to the above sketch?

I've used maxuino before which uses standard firmata.

can i just add the two together ? or just copy/paste the setup section :?

 : /  


PaulS

Quote
do you know of any code anywhere that i could add to the above sketch?

There is code posted every single day on the forum that you could add to the sketch. Whether you want to, or not, is a different issue.

What is it that you want the sketch to do that it is not doing? THAT is the code that you need to add.

qwerky

thank you for that Pauls.

Go Up