Go Down

Topic: Problem with looping shiftOut command (Read 681 times) previous topic - next topic

tobyb121

Are you testing with the USB connected? If so you can't use pins 0 and 1 as general purpose IO pins.
Why do you have a loop within a loop? your for loop inside the loop function, but nothing changes between each iteration of your loop, you don't use i anywhere, or increment any values.
Finally what is the benefit of B01000000 >>1? why not just use: B00100000 and not shift?


Are you testing with the USB connected? If so you can't use pins 0 and 1 as general purpose IO pins.


Are you talking about the UNO, if not the pins are the ATTinys pins.


Why do you have a loop within a loop? your for loop inside the loop function, but nothing changes between each iteration of your loop, you don't use i anywhere, or increment any values.


The for loop is one pattern, so that is only one pattern. The i should change as I have used the same for loop before.


Finally what is the benefit of B01000000 >>1? why not just use: B00100000 and not shift?


As I said in my first post, I am new to coding, but I do understand the basic concepts. I did that because it was in the last code that I wrote before posting and it worked, I have tried the following for the 8 bits: B01000000 >> 8; B01000000 >> 4; B01000000.


I still haven't seen any code that does compile.


The code was changed in the first post and it does compile.

Nick Gammon

Quote
B01000000 >> 8;


That will be zero, so you may as well just write: 0
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

guix

(Assuming you use 595's shift registers) I always recommend to read this and try the small library at the end: http://bildr.org/2011/08/74hc595-breakout-arduino

Go Up