Hey folks.
How would I go about coding something like a"ShiftIn" function? I have a "clock in" and a "data in", and I want to print the results to the serial port.
Thanks in advance! ;D
Hey folks.
How would I go about coding something like a"ShiftIn" function? I have a "clock in" and a "data in", and I want to print the results to the serial port.
Thanks in advance! ;D
Well, I didn't look around but heres one I wrote for a project of mine.
int shiftIn() {
int cwt;
cwt=0;
bitmask=128;
while (bitmask >= 1) {
digitalWrite(shtClk, HIGH);
cwt = cwt + bitmask * digitalRead(shtData);
digitalWrite(shtClk, LOW);
bitmask=bitmask/2;
}
return(cwt);
}
That is for MSB first, other end changes data on rising edge of the clock.
Hmm.. Isn't the Clock an input too? :-/
Sorry, the code there is for having the microcontroller do the clocking. I've never had the need to use an external clock.
I might check to see if i2c could be used, since the avr's support this. Or, perhaps you could attach an interrupt. What are you trying to interface to?