Pages: 1 [2]   Go Down
Author Topic: Problem with looping shiftOut command  (Read 612 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 9
Posts: 254
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 510
Posts: 19303
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
B01000000 >> 8;

That will be zero, so you may as well just write: 0
Logged

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

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

France
Offline Offline
Edison Member
*
Karma: 38
Posts: 1012
Scientia potentia est.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(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
Logged

Pages: 1 [2]   Go Up
Jump to: