error: 'F' was not declared in this scope?? but i did!

hello all,

this is kinda strange. my code worked fine in arduino 0022 but the the IDE stopped so i downloaded arduino 1.0 now with the same code i have strange error messages?

there is NO additional libary needed. in fact i did declare "F" as you can see in my code below.

any help is aprechiated

thanks peroja

sketch_jan28a.cpp: In function 'void digit0()': sketch_jan28a.pde:-1: error: 'F' was not declared in this scope sketch_jan28a.cpp: In function 'void digit1()': sketch_jan28a.pde:-1: error: 'F' was not declared in this scope sketch_jan28a.cpp: In function 'void digit2()': etc...

here is the code:

/*
Arduino 4 digits 7 segments LED countdown timer with buzzerm from
electronicsblog.net. If You share/use this code elsewhere on the internet
please meantion this code source.
*/

// segment | Arduino board PIN number 

#define G 6
#define F 7
#define A 8
#define B 9
#define E 10
#define D 11
#define C 12
#define DP 13

// Commonn cathodes control
#define GND1 2
#define GND2 3
#define GND3 4
#define GND4 5

// buttons
/*
Button_start - start/pause timer and in setup mode inreases minutes
and seconds values
Button_set - if timer is paused it resets timer to start. Long press
activates setup mode in which button is for going through minutes, seconds setup
and leaving setup mode.

*/

#define Button_start A0
#define Button_set A1

///
#define Buzzer 1
#define LED 0 // or relay insted

int i=0;
char run=0; // shows if timer is runnig
int b=0;  //for buttons
int c=0;
int d=0; // for buzzer
char set_mode=0; // shows if timer is in setup mode
char alarm =0;  // if "1" buzzer is on

//timer variables

// user setted and "turn on" values
int default_Sec=00;
int default_Min=00;

// current values
int Sec;
int Min;

//timer interrupt

ISR(TIMER1_OVF_vect) {
Sec--; // timer values decreases
TCNT1=0x0BDC;
  
}

// functions to display digits

void digit0 () {
// for 0 needed to turn ON F A B C D E segments, so:

digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);

//////////////////////// G segment should be turn OFF
digitalWrite(G, LOW);

};

void digit1 () {

digitalWrite(A,LOW);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
};

void digit2 () {

digitalWrite(A,HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
};

void digit3 () {

digitalWrite(A,HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
};

void digit4 () {

digitalWrite(A,LOW);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
};

void digit5 () {

digitalWrite(A,HIGH);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
};

void digit6 () {

digitalWrite(A,HIGH);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
};

void digit7 () {

digitalWrite(A,HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
};

void digit8 () {

digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);

};

void digit9 () {

digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);

};

//function to display digit from inputed int

void showdigit (int digit)

{
  
 switch (digit) {

 case 0:
 digit0 ();
 break;

 case 1:
 digit1 ();
 break;

 case 2:
 digit2 ();
 break;

 case 3:
 digit3 ();
 break;

 case 4:
 digit4 ();
 break;

 case 5:
 digit5 ();
 break;

 case 6:
 digit6 ();
 break;

 case 7:
 digit7 ();
 break;

 case 8:
 digit8 ();
 break;

 case 9:
 digit9 ();
 break;

 default:



 break;



 }; 

};

// showing 4 digits
//  not only shows 4 digit number, but also there is option to turn on
//only selected digits and decimal point.

void showdigits (int number, char digit_on, char  decimal_point)
{

  

digitalWrite(GND4, LOW);
  // e.g. we have "1234"
showdigit(number/1000);  // segments are set to display "1"
if (decimal_point&8) {digitalWrite(DP, HIGH);} else {digitalWrite(DP, LOW);};
 if (digit_on&8) {
digitalWrite(GND1, HIGH); // first digit on,
digitalWrite(GND2, LOW); // other off
digitalWrite(GND3, LOW);
 }
 delay (1);

number = number%1000;  // remainder of 1234/1000 is 234
digitalWrite(GND1, LOW); // first digit is off
 showdigit(number/100); //// segments are set to display "2"
if (decimal_point&4) {digitalWrite(DP, HIGH);} else {digitalWrite(DP, LOW);};
 if (digit_on&4) {
digitalWrite(GND2, HIGH); // second digit is on
  } delay (1);// and so on....

number =number%100;    
digitalWrite(GND2, LOW);
showdigit(number/10);
if (decimal_point&2) {digitalWrite(DP, HIGH);} else {digitalWrite(DP, LOW);};
 if (digit_on&2) {
digitalWrite(GND3, HIGH);
 }
 delay (1);

number =number%10; 
digitalWrite(GND3, LOW);
showdigit(number); 
if (decimal_point&1) {digitalWrite(DP, HIGH);} else {digitalWrite(DP, LOW);};
 if (digit_on&1) {
digitalWrite(GND4, HIGH);
  }
  delay (1);

}; 

void setup()

{

  
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
pinMode(E, OUTPUT);
pinMode(F, OUTPUT);
pinMode(G, OUTPUT);
pinMode(DP, OUTPUT);

pinMode(GND1, OUTPUT);
pinMode(GND2, OUTPUT);
pinMode(GND3, OUTPUT);
pinMode(GND4, OUTPUT);

pinMode(Button_start, INPUT);
digitalWrite(Button_start, HIGH); //pull up resistor

pinMode(Button_set, INPUT);
digitalWrite(Button_set, HIGH); //pull up resistor

pinMode(Buzzer, OUTPUT);
pinMode(LED, OUTPUT);

TIMSK1=0x01; // enabled global and timer overflow interrupt;
TCCR1A = 0x00; // normal operation 148 page (mode0);

TCNT1=0x0BDC;

TCCR1B = 0x00; // stop hardware timer

// loading default timer values

Sec = default_Sec ; 
Min = default_Min ;

};
void loop ()

{
 //////////// button_start////////// 
  if (!digitalRead(Button_start)&&!b) {
  
  if (!set_mode) { if (run) {TCCR1B=0x00; run=0;} else {TCCR1B=0x04; run=1;}}
  
  if (set_mode==1) {Min++;}
  
   if (set_mode==2) {Sec++;}
      
   if (set_mode) {b=25;} else b=100;
  
         };
         
 if (!digitalRead(Button_start)&&b==1) {
     
        };       

if (!b==0) b--;

 //////////// button_set///////// 
 if (!digitalRead(Button_set)&&!c) {
  
   if(!run&&!set_mode) {Min=default_Min; Sec=default_Sec;}
            
  if (set_mode>0) set_mode++;
  
  if (set_mode==3) {set_mode=0;  default_Sec = Sec ;
default_Min = Min; }
  
   c=100;      };   
   
 if (!digitalRead(Button_set)&&c==1&&!run) {
   
     set_mode=1;
     
     c=100;
   
        };       

if (!c==0) c--;
////////////////////////////

if (set_mode) {if (Sec==60) {Sec=00;} 

 if (Min==100) {Min=0;} }

      
       else {

 if (Sec==-1) {Min--;Sec=59;}

 }  


//decimal point indication control 

if (!set_mode) {
  
  
  if (!(Sec%2)) { showdigits (Min*100+Sec,0x0F,0x04); } //0X00

else  {showdigits (Min*100+Sec,0x0F,0x00); }; //0000

} else {
  
  if (set_mode==1) {
  
  showdigits (Min*100+Sec,0x0F,0x0C);   //XX00
                                } else {
                     
                     
                     
                     showdigits (Min*100+Sec,0x0F,0x03);      } //00XX

}
if (run) {  // to do while timer is running; e.g. control relay 

digitalWrite(LED, HIGH);

} else digitalWrite(LED, LOW);

if ((Min==0)&&(Sec==0)&&run) {
run=0;
TCCR1B=0x00; //stop timer

//// to do after count down is finished e.g. start alarm as in this example

alarm=1;
d=500;

}

// Alarm part
if (alarm) { if (!(d%100)) { // sound 500/100= 5 times ;
  tone(Buzzer, 440, 200); }
  d--; 
  if (d==0) {alarm=0; Sec = default_Sec ;
  Min = default_Min ; // After alarm is off, timer goes to start
          }
    }  
  
};

Not really sure. If you replace the

#define F 7

with

const int F = 7;

its fine. I wonder if its something to do the F() macro that's in 1.0.

#define F 7

Arduino 1.0 also defines an F macro. I suspect changing your F to something else (e.g. "pF" for pin-F) will resolve the problem.

hello

yes i did change it into X

compiling is no problem but uploading says something error with SDK500? uhmmm....

Peroja:
any help is aprechiated

Peroja-

I realized you solved your posted problem, but you would be well advised to spend a bit of time reading up on how arrays work (start someplace like http://arduino.cc/it/Reference/Array) and think about how you could improve your program by using arrays.

And it’s even a bit harder to grasp, but reading the BitMath page (http://www.arduino.cc/playground/Code/BitMath) will reveal a short-cut to driving 8-segment displays.

For example, here is some code I used in a project to show the current temperature on a pair of Numitron tubes (think of them as a pair of 8-segment displays):

...

// Table for each seven-digit segment
PROGMEM prog_uint8_t digits[10] = {
  B1111011,                      // Zero  
  B1100000,                      // One  
  B1010111,                      // Two
  B1110110,                      // Three
  B1101100,                      // Four  
  B0111110,                      // Five
  B0111111,                      // Six
  B1110000,                      // Seven  
  B1111111,                      // Eight
  B1111110                       // Nine
};

...

void loop()
{

  ...

  // Now handle the display
  setupTLC(temp_tens, 0);        // Setup Tens digit
  setupTLC(temp_ones, 8);        // Then the Ones digit
  Tlc.update();                  // Update the display
  delay(3000);                   // Wait a bit... 
}

// Pull digit from program memory and decode bits
void setupTLC(int digit, int offset) {
  byte data = pgm_read_byte (&digits[digit]);   
  for (int i=0; i < 7; i++)
    if (data & (1<<i)) 
       Tlc.set(offset + i, 4095);
}

I know this is different hardware, but if you modify the setupTLC function to do a digitalWrite instead of a Tlc.set, and then change the digit definitions at the top of the code, you should be able to simplify your code considerably.

Might be a bit much, but I thought it might help.

Brad.

Brad, thanks. i did not write the code myself. i have it from a website. anyway i now have this error while uploading:

avrdude: stk500_getsync(): not in sync: resp=0x00

strange

Hello, ive been noticing that error (the most recent) a lot in arduino 1.0, what works with me (because my desktop is a dinosaur) is to do one of the following:
-try a different serial port
-try a different usb port
-unplug and replug in your arduino
Hope that helps!

Hello! I have recently had that error and what I had to do to fix it was make sure that the board was the proper one.

If you are using an Uno make sure that the Uno is selected.

If you are using something else make sure that board is selected.

Hope this helps!

-TECman-