Go Down

Topic: Coding Question: Making a ShiftIn (Read 691 times) previous topic - next topic


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;
 while (bitmask >= 1) {
   digitalWrite(shtClk, HIGH);
   cwt = cwt + bitmask * digitalRead(shtData);
   digitalWrite(shtClk, LOW);

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?

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131