Hi,
I' ve just started using arduino, and I've already a problem..
Well.. I wanted to make simple counter, which will count single pulses on a 4 digit 7 segment display. I made something like that, for now:
void setup() {
pinMode(1, OUTPUT); // D1
pinMode(2, OUTPUT); // D2
pinMode(3, OUTPUT); // D3
pinMode(4, OUTPUT); // D4
pinMode(5, OUTPUT); // a
pinMode(6, OUTPUT); // b
pinMode(7, OUTPUT); // c
pinMode(8, OUTPUT); // d
pinMode(9, OUTPUT); // e
pinMode(10, OUTPUT); // f
pinMode(11, OUTPUT); // g
pinMode(12, INPUT); // conter entrance
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
// zero, as a starter
}
void one() { // 1
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}
void two() { // 2
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
digitalRead(12); // check Button on pin 12
if(digitalRead(12) == HIGH){ // If it s pressed, show 1 number
one();
}
digitalRead(12); // check Button on pin 12
if(digitalRead(12) == HIGH) { // If it s pressed, show 2 number
two()
}
}
But of course it is not working, as I would like it to. Instead if I push button, 2 digits are shown, instead of 1.
I came up also with this:
digitalRead(12)
if (digitalRead(12) == HIGH) && (void one = HIGH);{
two() // If the Button is pushed and the programm is running, then show the 2 number
}
}
But it also is not working. It gave me an error: error: expected identifier before '(' token
I tried other things, but I didn't get better results.
I would be so happy, If someone helped me