Uno and 74hc4017b

Hello,

I am trying to get the Arduino uno to run 2 74hc4017B Johnson decade counter that are chained to each other. I have the circuit running great just having trouble with the sketch. I would like the program to send a clock pulse to keep the circuit counting, and use the "v" key of my computers keyboard to control the reset, off and on and control the enable, on and off with the "b" key. ty so much for any help, Derek

Data sheet: http://www.ti.com/lit/ds/symlink/cd74hc4017.pdf

I think it would be as simple as sending a "blink" like pulse through 1 pin and setting two other pins to change there state from high to low , holding there state till the v or b keys are used again.

TY, Derek

What is your question? This forum is not a program writing vending machine.

How to sketch a program that uses a keyboard key to change the state of a pin, high to low, hold that state till the key is pressed again. Sorry I know this is basic but I just bought my Arduino so Im learning.

Derek

This does more than you want, but you should get the idea: http://arduino.cc/en/Tutorial/ReadASCIIString

I have the circuit running great just having trouble with the sketch.

What does this mean, EXACTLY ? How do you know the circuit is "running great' if the sketch doesn't work ?

By using a LM555 as a astable multivibrator, http://www.ti.com.cn/cn/lit/ds/symlink/lm555.pdf . Connecting pin 3 of the 555, the output pin to pin 14 on the 74hc4017b, the CP0 clock input pin. I had 4 4017 "chained" together and also built a 5v power supply with the LM7805 to power it all before I got the arduino uno. I'm now tryng to control the reset pin and enable pin of the 4017, off till arduino pin goes high, then high till the same pin goes low. also I am sending the clock pulse via pin 9 on the arduino I'm just banging my head against a wall learning C/C++ to get the code right. But I am having a good time with it.

Derek

You just gave us the hardware SITREP (mil-speak for SITUATION REPORT) but now you have to give us a software SITREP. You have not posted any code and frankly I don't see why you should be banging your head against the wall for such a simple program. The problem is you are posting about a problem with a circuit for which you have not posted a schematic (not even a photo of a hand drawn schematic) and your claiming problems with code which you also have not posted. I don't know how you think we are supposed to help you if you are not going to post a schematic of your circuit and your code.

Sorry I don have the software to make the schematic. I didn't think I would need it to get help with a code I'm sure is simple for most of you guys, just not a beginner like me, I have owned a microcontroller for a week now. Just was asking if someone could tell me how to get the thing to see I pressed "a" on the keyboard and turn a pin high, then if I pressed "a" again it sets it low. Maybe microcontrollers and programming isn't my thing.

thanks any way, Derek

battleshy: Sorry I don have the software to make the schematic.

Draw a clear diagram with pencil and paper and post a photo of your drawing.

...R

This is close to the circuit I built, I’m using a fixed value resistor, I have to 4017 “chained” together and I used 10 pin instead of 8. Pretty neat circuit. Cycles through 10 led on first 4017 0-9 then when that chip reset to 0 it sends a pulse to the next chip causing it to advance 1 pin. Repeats for as many 4017 as you have chained. With 4 4017 my circuit counted to 10,000 ie… 10,000 clock pulses then reset back to 0.
Picture is from,
http://www.gadgetronicx.com/2012/07/disco-led-lights.html

Derek

dancing-_light-circuit.jpg

Use Timer1 library (to generate clock to connect to pin-16 of 4017, See attached to find the pins decribed below)
http://playground.arduino.cc/Code/Timer1

Note that timer1 can be used on a Mega but does not support all three output pins OCR1A, OCR1B & OCR1C

Maybe microcontrollers and programming isn't my thing.

What kind of attitude is that ? With that attitude you've failed before you have even started. Start thinking positive. You'll find it gets better results.

raschemmel ,

OK, I took my arduino out of my circuit and went back to using the 555 for the clock pulse. I add a push button to my circuit to interrupt the pulse.

(Blink) example:

// Pin 9 clock pulse. int led = 9; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }

Sends clock pulse every 1000 ns I believe, I was trying to use my computer keyboard as the button. The button pulls pin 15 high to reset the 4017. When I release the button pin 15 of the 4017 goes low again allowing the circuit to begin counting again.

Where I ran into my issue, using the computers keyboard as an input to the arduino to change the state of say pin 5 of the arduino from high to low by pressing a button on my keyboard say..... button "a". Then reverse pin 5 state when that button is pushed again. Pin 5 of the arduino would be hooked to pin 15 of my 4017s so when pin 5 is high on arduino, pin 15 would be high on the 4017.

I dont need the arduino as a power supply, I can build those, or a pulse generate, I can build those also. I wanted arduino to interface my computer into my electronic projects.

TY to all those who tried to help and good luck on your projects, Derek

It sounds like you need to break your learning process into four separate parts.

Simplest part is probably to get the Arduino to switch am I/O pin from LOW to HIGH to LOW to cause the 4017 to move forward won step. Write a short sketch that does that, and nothing else. You can use delay() to manage the timing but it would be much better (for you) if you learn how to use the technique in the Blink Without Delay example sketch.

Next part is to write a short sketch that causes the LOW HIGH LOW sequence to occur when you press a switch attached directly to the Arduino. For this sort of switch I just use two wires stuck into the Arduino pins and touch the wires together to make the switch.

Third part is to write a short sketch that can receive characters from the PC and cause an LED to light.

Fourth part is to bring all the parts together.

I suspect that the examples that come with the Arduino IDE cover each of parts 1 to 3.

...R

I am trying to get the Arduino uno to run 2 74hc4017B Johnson decade counter that are chained to each other. I have the circuit running great just having trouble with the sketch. I would like the program to send a clock pulse to keep the circuit counting, and use the "v" key of my computers keyboard to control the reset, off and on and control the enable, on and off with the "b" key. ty so much for any help,

Where I ran into my issue, using the computers keyboard as an input to the arduino to change the state of say pin 5 of the arduino from high to low by pressing a button on my keyboard say..... button "a". Then reverse pin 5 state when that button is pushed again. Pin 5 of the arduino would be hooked to pin 15 of my 4017s so when pin 5 is high on arduino, pin 15 would be high on the 4017.

to change the state of say pin 5 of the arduino from high to low by pressing a button on my keyboard say..... button "a". Then reverse pin 5 state when that button is pushed again.

int ledPin =13;
int pinFIVE = 5;
boolean pin5_State= false;
void setup()
{
Serial.begin(9600); // Starts serial data
pinMode(ledPin, OUTPUT);
pinMode(pinFIVE, OUTPUT);


}
void loop()
{
  if (Serial.available() > 0) 
  {
      char inByte = Serial.read(); // waits untill somthing is typed
      if (inByte == 'a' && pin5_State == LOW)
        {
          // change pin 5 state
          digitalWrite(pinFIVE, HIGH);
          digitalWrite(ledPin, HIGH);
          Serial.print(" pin5_State = ");
          Serial.println(pin5_State); // shows what was stored
          pin5_State = true;
          
         }
         else
         {
         if (inByte == 'a' && pin5_State == HIGH)
            {
             digitalWrite(pinFIVE, LOW);
             digitalWrite(ledPin, LOW);
             Serial.print(" pin5_State = ");
             Serial.println(pin5_State); // shows what was stored
             pin5_State = false;
            }
         }  
         Serial.print(" I got: ");
         Serial.println(inByte); // shows what was stored
   }
}

That pretty sound advice.

Thanks, Derek

raschemmel ,

Wow very nice sketch, ty I'll dissect with my C/C++ reference guides to see what it all means. Your sketch is starting out LOW then upon entering 'a' and only 'a' it advances the 4017 once ie.. allows pin 13 of your sketch to go HIGH briefly, after entering 'a' two more times pin 13 goes HIGH briefly again. Its a leap forward from where I was at with my sketch and a really good platform to build from.

Thanks again, Derek

I tested it. It TOGGLES pin 5 and 13 every time you enter an 'a'.

FYI, All you have to do to add more commands is clone the code for entering 'a' and change it to whatever you want and add or change the code so it does more that turn on/off 5 & 13.

Yep code is working great. Thank you.

Derek