Mod-12 counter and 4 to 16 decoder

Hi guys I'm currently doing a project using mod-12 counter, arduino uno and 4 to 16 decoder. I'm new to programming and i need some help even though it is easy. I've patch up the circuit, now i have to connect the arduino in between the mod-12 counter and decoder. In other words, the mod-12 counter will send binary to the arduino first then to the decoder. It will count from 0 to 11 every time i pressed a button unless the arduino sends an interrupt and change the sequence.

I just need to know the program code to control the I/O pins of arduino to send the binary. Thank you!!

No idea what you mean.

They say a picture is worth a thousand words. How about drawing us some block diagrams, schematics, etc.

Also, maybe telling us just what you want to achieve would help.

The mod-12 counter will send binary for example 0001, 0010, 0011, ... and so on from 0 to 11 to arduino board every time i press the button on the circuit, then the board will send the binary to the decoder and number will display on 7-seg. So there will be 4 inputs and 4 outputs for the arduino board. I'm not sure on how to write the program on this.

So I need to know how to write the program on this and that would help alot!

I have to ask... why an external binary counter?

I using the arduino for interrupt the sequence by sending sms from the user. So the counter is from push button switch and mod-12 counter.

Yes, I gathered that, but why does the counter even exist? Why do you feel you need the counter in there at all? What is wrong with wiring the button direct to the Arduino and having that do the counting? You seem to be needlessly adding extra complexity to what is a very simple job.

At this point, I don't see the purpose of the Arduino, but if you're hell bent on having it there your sketch just needs to to a pinMode on 8 pins, half being input, half being output, and every pass through the loop, digitalWrite an ouput pin to the result of a digitalRead of another.

My arduino is use for sending sms to change the sequence..so without any interruption from the sms the sequence will be 0-11 using external counter

It's my proj that requires me to use mod-12 counter and external counter

So, this is homework then? Using an external counter for this seems a really silly thing to do.

Yea it's an proj that requires arduino which i nvr encounter it before. I not sure how to write the code for that

vendettaa:
I not sure how to write the code for that

That's the case with most projects, you have to figure it out. I'm sure you homework assignment didn't include having someone write the code for you.

Yea it's an proj that requires arduino

So why do you want to cheat. Any grade you get from cheating is not valid because you didn't learn anything.

not asking for the code but juz wanna understand how to do it, like what arrch had said above

vendettaa:
not asking for the code but juz wanna understand how to do it, like what arrch had said above

So try it. If it doesn't work, post what you have here, with code tags, and explain both what it is doing (be specific) and what you are expecting it to do (again, be specific).

So i am trying to get the mod-12 counter to send the binary to my arduino board, from the board to the decoder. I've alrdy patch up the circuit counting from 0 to 11. The arduino will only interrupt the count sequence when i send sms to it, other than that it will just transfer the binary to decoder. The code below is to set the input and output ports of the board to transfer the binary but it could not work. The count sequence is weird.

int input1 = 2;
int input2 = 3;
int input3 = 4;
int input4 = 5;

int output1 = 6;
int output2 = 9;
int output3 = 10;
int output4 = 11;

void setup()
{
   pinMode(input1, INPUT);
  pinMode(input2, INPUT);
  pinMode(input3, INPUT);
  pinMode(input4, INPUT);
  pinMode(output1, OUTPUT);
  pinMode(output2, OUTPUT);
  pinMode(output3, OUTPUT);
  pinMode(output4, OUTPUT);
}

void loop()
{
  if (digitalRead(input1))
  digitalWrite(output1, HIGH);
  if (digitalRead(input2))
  digitalWrite(output2, HIGH);
  if (digitalRead(input3))
  digitalWrite(output3, HIGH);
  if (digitalRead(input4))
  digitalWrite(output4, HIGH);
 
}

Of course it is - you're only ever setting the outputs HIGH, never LOW.

so i copy and paste the content in loop and change the output to LOW?

Try learning the keyword "else".

Alright thanks