79Views8Replies

Author Options:

I would like to shift a logic 1 though pins 10, 11, 12 and 13 by a pulse at pin 2 from button inputs. please help. Answered


On an Aduino no
I would like to make pin 2 an input. Pin 10, 11, 12 and 13 out puts which will go high then low in turn on subsequent pulses on pin 2. I want to drive 4 LEDs one after the other on and off. If I press and release button at pin 2, led 10 comes on. when I press the button the second time, LED 10 goes off then LED 11 comes. on the next input pulse LED 11 goes off and LED 12 comes on. On the next pulse LED 12 goes off and LED 13 comes on.on the next pulse LED 13 goes off and LED 10 goes on again 

Please help

Discussions

0
nyama
nyama

3 years ago

what if I count the input signals. Like count =0; digital write 10 high.

count = 1; digital write 10 low

digital write 11 high

count = 2; digital write 11 low

digital write12 high

count = 3 digital write 12 low

digital write 13 high

count = 4 digital write 13 low

rest count

0
nyama
nyama

3 years ago

Thank you. at list Now I know what it takes to achieve this.

0
-max-
-max-

3 years ago

You could just use a shift register, which is specifically designed for the task, instead of what I am guessing is an Arduino. You should have a few 74HC595's if you got a decent arduino kit. If not, you should get them, as they are very useful in for converting serial data into parallel data.

The basic shift register is just a series of D flip flops, with the output of one connected to the next, and all sharing a common clock and reset. So you have an input, and a clock. When the clock triggers on a rising edge, data gets shifted through, new bits come in, and old ones get lost.

0
nyama
nyama

Answer 3 years ago

Very sorry I forgot to mention this is on an aduino uno. I am a newbie and I have run the examples in the library. But I cannot find an example to do this. I know of Shift registers , but I would like My aduino to perform like a shift register.

Thank you

0
-max-
-max-

Answer 3 years ago

I can think of many ways to do that on arduino, the fastest, "best" way is probably going to involve using hardware interrupts for the incoming clock "port manipulation" and bitwise operands. (<< and >>)

http://playground.arduino.cc/Learning/PortManipulation

But for a beginner that might be a little advanced, and if you do not need the code to be particularly fast, then you might be able to use some if else blocks and when a signal is digitalRead on whatever pin you want to define as the clock input, then another pin is digitalRead and then you just have a bunch of Digital Writes for all the other pins.

You will end up needing to "remember" the value of each and every single pin's current state, so an array of booleans or a bunch of separate booleans variables need to be defined.

0
Raptor217
Raptor217

Answer 3 years ago

I don't know if an arduino has a button debouncer built in, but nyama will want that for sure to eliminate headache.

0
-max-
-max-

Answer 3 years ago

Good idea, typically I just use a capacitor for that, put one (like 1nF --- 100nF, or whatever) directly across the switch contacts and you're golden. Not the absolute best solution for the longevity of a tiny dome switch, but meh, for DIY, who cares, it's easy!