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!!
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!
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.
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);
}