OK, so I'm beginning to work with custom functions and I really thought I had a handle on it. Wrote a couple for the last sketch with minimal trouble. I've been scrutinizing the difference between the functions in the previous (and related) sketch and the current(see below). Banged my head against the wall for a while now....can't figure out what I've done for the life of me. Thanks for your help!
I've highlighted the functions in question by bold/underline.
==================
DEBUGGER
Error message from debugger:
Arduino: 1.8.7 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users....\Documents\Arduino\7seg_2switches\7seg_digit_func\7seg_digit_func.ino: In function 'void loop()':
7seg_digit_func:61:16: error: 'disp_1' was not declared in this scope
disp_1(a, f);
^
7seg_digit_func:64:25: error: 'disp_2' was not declared in this scope
disp_2(a, b, d, g, h);
^
C:\Users,,,,,\Documents\Arduino\7seg_2switches\7seg_digit_func\7seg_digit_func.ino: In function 'void slowBlink(int, int)':
7seg_digit_func:80:29: error: a function-definition is not allowed here before '{' token
void disp_1(int a, int f) {
^
7seg_digit_func:91:50: error: a function-definition is not allowed here before '{' token
void disp_2(int a, int b, int d, int g, int h){
^
7seg_digit_func:103:3: error: expected '}' at end of input
}
^
exit status 1
'disp_1' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
==================
SKETCH
// Enable all 7-seg display to output
int a = 4; pinMode(a, OUTPUT);
int b = 5; pinMode(b, OUTPUT);
int c = 6; pinMode(c, OUTPUT);
int d = 7; pinMode(d, OUTPUT);
int e = 8; pinMode(e, OUTPUT);
int f = 9; pinMode(f, OUTPUT);
int g = 10; pinMode(g, OUTPUT);
int h = 11; pinMode(h, OUTPUT);
const int lhInput = 2;
const int rhInput = 1;
// RH switch input
pinMode(rhInput, INPUT);
// LH switch input
pinMode(lhInput, INPUT);
}
void loop() {
// Designate all 7seg terminals by alphabet (pursuant to diagram in journal)
int a = 4;
int b = 5;
int c = 6;
int d = 7;
int e = 8;
int f = 9;
int g = 10;
int h = 11;
// Define input pins
const int lhInput = 2;
const int rhInput = 1;
// Designate output pins
const int decimal = e;
// switch-state variables, initialized to false (no button presses)
boolean lhState = LOW;
boolean rhState = LOW;
// delay to give the feel of a loop reset
delay(2000);
// delay and # of LED pulses
int delayPeriod = 250;
int pulses = 6;
// read switch state
lhState = digitalRead(lhInput);
rhState = digitalRead(rhInput);
if (lhState == HIGH && rhState == LOW) {
disp_1(int a, int f);
}
if (lhState == LOW && rhState == HIGH) {
disp_2(a, b, d, g, h);
}
else {
slowBlink(delayPeriod, decimal);
}
}
void slowBlink(int delayPeriod, int decimal) {
for (int j = 0; j <= 3; j++) {
digitalWrite(decimal, HIGH);
delay(delayPeriod * 5);
digitalWrite(decimal, LOW);
delay(delayPeriod * 5);
}
// Display digit 1 on 7-segment display
void disp_1(int a, int f) {
// Turn on segments
digitalWrite(a, HIGH);
digitalWrite(f, HIGH);
delay(3000);
digitalWrite(a, LOW);
digitalWrite(f, LOW);
}
// Display digit 2 on 7-segment display
void disp_2(int a, int b, int d, int g, int h) {
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(d, HIGH);
digitalWrite(g, HIGH);
digitalWrite(h, HIGH);
delay(3000);
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(d, LOW);
digitalWrite(g, LOW);
digitalWrite(h, LOW);
}