Arduino Forum

Products => Arduino Due => Topic started by: Strontium on Sep 22, 2013, 06:43 am

Title: Error with tone library
Post by: Strontium on Sep 22, 2013, 06:43 am
First of all, here is my code:
Code: [Select]
#include <Tone.h>

#define enter 48

Tone = tone1;

void setup() {
 pinMode(53, INPUT);
 pinMode(51, INPUT);
 pinMode(49, INPUT);
 pinMode(47, INPUT);
 pinMode(45, INPUT);
 pinMode(52, OUTPUT);
 pinMode(50, OUTPUT);
 pinMode(48, OUTPUT);

}

void loop() {
 if (enter == HIGH) {
   if (53 == HIGH && 51 == HIGH && 49 == LOW && 47 == LOW && 45 == LOW) {
     digitalWrite(48, HIGH);
   }
   else {
     tone1.begin(52);
     tone1.play(262, 500);
   }
 }
}


Whats happening is it checks if the passcode is correct, and if it is, it lights up an LED. If it isn't, it makes a buzzing noise.

Heres the problem:
I cannot get the tone library to work correctly. (This specific tone library: https://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation).

Here is my error message (Verbose mode):
Code: [Select]
Arduino: 1.5.3 (Mac OS X), Board: "Arduino Due (Programming Port)"

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/g++_arm_none_eabi/bin/arm-none-eabi-g++ -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=153 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Due" -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/CMSIS/Include/ -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/ -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/cores/arduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/variants/arduino_due_x -I/Users/mmforde1/Documents/Arduino/libraries/Tone /var/folders/yz/cqtyzg8n7w1c0bf40mv6w8dw0000gn/T/build5746105419377166516.tmp/Passcode.cpp -o /var/folders/yz/cqtyzg8n7w1c0bf40mv6w8dw0000gn/T/build5746105419377166516.tmp/Passcode.cpp.o
Passcode:8: error: expected constructor, destructor, or type conversion before '=' token
Passcode.ino: In function 'void loop()':
Passcode:28: error: 'tone1' was not declared in this scope


I am using an Arduino Due, and am uploading via the programming port.

Can someone please explain why this is happening?

Please excuse any silly mistakes I made, because an 11 year old brain doesn't have the mental capacity to create good code.
Title: Re: Error with tone library
Post by: MichaelMeissner on Sep 22, 2013, 06:54 am

First of all, here is my code:
Code: [Select]
#include <Tone.h>

#define enter 48

Tone = tone1;


Please excuse any silly mistakes I made, because an 11 year old brain doesn't have the mental capacity to create good code.

Your problem is on the last line I quoted.  You should not have the equal sign for that line.  The correct line should be:

Code: [Select]

Tone tone1;


What this does is create a variable by the name tone1 that is of the class Tone.  You then use tone1 else where in the program.
Title: Re: Error with tone library
Post by: Strontium on Sep 22, 2013, 06:59 am


First of all, here is my code:
Code: [Select]
#include <Tone.h>

#define enter 48

Tone = tone1;


Please excuse any silly mistakes I made, because an 11 year old brain doesn't have the mental capacity to create good code.

Your problem is on the last line I quoted.  You should not have the equal sign for that line.  The correct line should be:

Code: [Select]

Tone tone1;


What this does is create a variable by the name tone1 that is of the class Tone.  You then use tone1 else where in the program.


Just tried that; new error:
Code: [Select]
Arduino: 1.5.3 (Mac OS X), Board: "Arduino Due (Programming Port)"

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/g++_arm_none_eabi/bin/arm-none-eabi-g++ -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=153 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Due" -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/CMSIS/Include/ -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/ -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/cores/arduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/variants/arduino_due_x -I/Users/mmforde1/Documents/Arduino/libraries/Tone /var/folders/yz/cqtyzg8n7w1c0bf40mv6w8dw0000gn/T/build5746105419377166516.tmp/Passcode.cpp -o /var/folders/yz/cqtyzg8n7w1c0bf40mv6w8dw0000gn/T/build5746105419377166516.tmp/Passcode.cpp.o
Passcode:8: error: 'Tone' does not name a type
Passcode.ino: In function 'void loop()':
Passcode:28: error: 'tone1' was not declared in this scope
Title: Re: Error with tone library
Post by: MichaelMeissner on Sep 22, 2013, 07:12 am
Arduino does not include the more general tone library.  You will have to go here to find the library, and then install it in the correct location on your system (~/sketchbook/libraries/<dir> on Linux, I don't remember where it is on other OSes).  http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation (http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation)

The Arduino base code has a simplified tone library.  It does not have a Tone class, and you can only generate one tone at a time.  That library is documented here: http://arduino.cc/en/Reference/Tone (http://arduino.cc/en/Reference/Tone).
Title: Re: Error with tone library
Post by: Strontium on Sep 22, 2013, 07:18 am

Arduino does not include the more general tone library.  You will have to go here to find the library, and then install it in the correct location on your system (~/sketchbook/libraries/<dir> on Linux, I don't remember where it is on other OSes).  http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation (http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation)

The Arduino base code has a simplified tone library.  It does not have a Tone class, and you can only generate one tone at a time.  That library is documented here: http://arduino.cc/en/Reference/Tone (http://arduino.cc/en/Reference/Tone).

The library I am using is installed.

I have tried using the other tone library, but I get a similar error to "tone() was not declared in this scope)", so I assume I need to include it, but I do not know the name of it.
Title: Re: Error with tone library
Post by: nickgammon on Sep 22, 2013, 07:59 am
Please post your modified code.
Title: Re: Error with tone library
Post by: Strontium on Sep 22, 2013, 08:00 am

Please post your modified code.

In what context?
Title: Re: Error with tone library
Post by: nickgammon on Sep 22, 2013, 08:08 am
Your original post had some code. Presumably you modified it? Can you post the new code please? In the context of this forum (whatever that means).
Title: Re: Error with tone library
Post by: Strontium on Sep 22, 2013, 08:11 am

Your original post had some code. Presumably you modified it? Can you post the new code please? In the context of this forum (whatever that means).

Alright. It hasn't really changed except for the first error I made (When I typed "Tone = tone1;" instead of "Tone tone1;".
Here it is:
Code: [Select]
#include <Tone.h>

#define enter 48

Tone tone1;

void setup() {
 pinMode(53, INPUT);
 pinMode(51, INPUT);
 pinMode(49, INPUT);
 pinMode(47, INPUT);
 pinMode(45, INPUT);
 pinMode(52, OUTPUT);
 pinMode(50, OUTPUT);
 pinMode(48, OUTPUT);

}

void loop() {
 if (enter == HIGH) {
   if (53 == HIGH && 51 == HIGH && 49 == LOW && 47 == LOW && 45 == LOW) { //Checking the passcode
     digitalWrite(48, HIGH);
   }
   else { //Plays if passcode is incorrect
     tone1.begin(52);
     tone1.play(262, 500);
   }
 }
}  
Title: Re: Error with tone library
Post by: nickgammon on Sep 22, 2013, 08:29 am
Code: [Select]

#define enter 48


And given that:

Code: [Select]

#define HIGH 0x1


Then:

Code: [Select]

  if (enter == HIGH) {


Is testing if 1 is equal to 48. Why do this?

Anyway, since this is a Due issue I'll move it to the Due part of the forum.
Title: Re: Error with tone library
Post by: Strontium on Sep 22, 2013, 08:53 am

Code: [Select]

#define enter 48


And given that:

Code: [Select]

#define HIGH 0x1


Then:

Code: [Select]

  if (enter == HIGH) {


Is testing if 1 is equal to 48. Why do this?

Anyway, since this is a Due issue I'll move it to the Due part of the forum.

I was trying to see if pin 48 was equal to 1/on/high. Since that doesn't work, how would I do it?

*Note to make sure that the tone library is going to be solved too, and not moving over to this new problem*
Title: Re: Error with tone library
Post by: nickgammon on Sep 22, 2013, 09:29 am
Code: [Select]

  if (digitalRead (enter) == HIGH) {
Title: Re: Error with tone library
Post by: Strontium on Sep 22, 2013, 06:56 pm

Code: [Select]

 if (digitalRead (enter) == HIGH) {


Ah. I am guessing that digital read checks the state of the specified pin?
EDIT:
Here is my new, modified code:
Code: [Select]
#include <Tone.h>

#define enter 48

Tone tone1;

void setup() {
  pinMode(53, INPUT);
  pinMode(51, INPUT);
  pinMode(49, INPUT);
  pinMode(47, INPUT);
  pinMode(45, INPUT);
  pinMode(52, OUTPUT);
  pinMode(50, OUTPUT);
  pinMode(48, OUTPUT);

}

void loop() {
  if (enter == HIGH) { //Run check process when "enter" is pressed
    if (digitalRead (53) == HIGH && digitalRead (51) == HIGH && digitalRead (49) == LOW && digitalRead (47) == LOW && digitalRead (45) == LOW) { //Checking the passcode
      digitalWrite(48, HIGH);
    }
    else { //Plays if passcode is incorrect
      tone1.begin(52);
      tone1.play(262, 500);
    }
  }
}   


I still get an error:
Code: [Select]
Arduino: 1.5.3 (Mac OS X), Board: "Arduino Due (Programming Port)"

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/g++_arm_none_eabi/bin/arm-none-eabi-g++ -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=153 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Due" -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/CMSIS/Include/ -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/ -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/cores/arduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/variants/arduino_due_x -I/Users/mmforde1/Documents/Arduino/libraries/Tone /var/folders/yz/cqtyzg8n7w1c0bf40mv6w8dw0000gn/T/build8539723148094633157.tmp/Passcode.cpp -o /var/folders/yz/cqtyzg8n7w1c0bf40mv6w8dw0000gn/T/build8539723148094633157.tmp/Passcode.cpp.o
Passcode:5: error: 'Tone' does not name a type
Passcode.ino: In function 'void loop()':
Passcode:25: error: 'tone1' was not declared in this scope


Now, using Arduino's simplified tone library (I have indeed moved the piezo to a PWM pin):
Code: [Select]
#define enter 48

void setup() {
  pinMode(53, INPUT);
  pinMode(51, INPUT);
  pinMode(49, INPUT);
  pinMode(47, INPUT);
  pinMode(45, INPUT);
  pinMode(2, OUTPUT); //*NOTE PIEZO
  pinMode(50, OUTPUT);
  pinMode(48, OUTPUT);

}

void loop() {
  if (digitalRead (enter) == HIGH) { //Run check process when "enter" is pressed
    if (digitalRead (53) == HIGH && digitalRead (51) == HIGH && digitalRead (49) == LOW && digitalRead (47) == LOW && digitalRead (45) == LOW) { //Checking the passcode
      digitalWrite(48, HIGH);
    }
    else { //Plays if passcode is incorrect
      tone(2, 262, 500);
    }
  }
}   

Error:
Code: [Select]
Arduino: 1.5.3 (Mac OS X), Board: "Arduino Due (Programming Port)"

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/g++_arm_none_eabi/bin/arm-none-eabi-g++ -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=153 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Due" -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/CMSIS/Include/ -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/ -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/cores/arduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/variants/arduino_due_x /var/folders/yz/cqtyzg8n7w1c0bf40mv6w8dw0000gn/T/build8539723148094633157.tmp/Passcode.cpp -o /var/folders/yz/cqtyzg8n7w1c0bf40mv6w8dw0000gn/T/build8539723148094633157.tmp/Passcode.cpp.o
Passcode.ino: In function 'void loop()':
Passcode:21: error: 'tone' was not declared in this scope


So, I tried using a snippet of code made by Calum (for his Song Of Storms Sketch) and it works! But its a little uglier:
Code: [Select]
#define enter 48
#define NOTE_C4  262
int speakerPin = 52;

void setup() {
  pinMode(53, INPUT);
  pinMode(51, INPUT);
  pinMode(49, INPUT);
  pinMode(47, INPUT);
  pinMode(45, INPUT);
  pinMode(52, OUTPUT);
  pinMode(50, OUTPUT);
  pinMode(48, OUTPUT);

}

void beep (unsigned char speakerPin, int frequencyInHertz, long timeInMilliseconds)  //code for working out the rate at which each note plays and the frequency.
{
  int x;     
  long delayAmount = (long)(1000000/frequencyInHertz);
  long loopTime = (long)((timeInMilliseconds*1000)/(delayAmount*2));
  for (x=0;x<loopTime;x++)   
  {   
    digitalWrite(speakerPin,HIGH);
    delayMicroseconds(delayAmount);
    digitalWrite(speakerPin,LOW);
    delayMicroseconds(delayAmount);
  }   
  delay(20);
}       

void loop() {
  if (digitalRead (enter) == HIGH) { //Run check process when "enter" is pressed
    if (digitalRead (53) == HIGH && digitalRead (51) == HIGH && digitalRead (49) == LOW && digitalRead (47) == LOW && digitalRead (45) == LOW) { //Checking the passcode
      digitalWrite(48, HIGH);
    }
    else { //Plays if passcode is incorrect
      beep(speakerPin, NOTE_C4, 500);
    }
  }
}   


So now, I shall upload it to my arduino and see if I did anything wrong.
Title: Re: Error with tone library
Post by: Strontium on Sep 22, 2013, 07:17 pm
So, I ran the code (here it is, by the way:
Code: [Select]
#define enter 48
#define NOTE_C4  262
int speakerPin = 52;

void setup() {
 pinMode(53, INPUT);
 pinMode(51, INPUT);
 pinMode(49, INPUT);
 pinMode(47, INPUT);
 pinMode(45, INPUT);
 pinMode(52, OUTPUT);
 pinMode(50, OUTPUT);
 pinMode(48, INPUT);

}

void beep (unsigned char speakerPin, int frequencyInHertz, long timeInMilliseconds)  //code for working out the rate at which each note plays and the frequency.
{
 int x;      
 long delayAmount = (long)(1000000/frequencyInHertz);
 long loopTime = (long)((timeInMilliseconds*1000)/(delayAmount*2));
 for (x=0;x<loopTime;x++)    
 {    
   digitalWrite(speakerPin,HIGH);
   delayMicroseconds(delayAmount);
   digitalWrite(speakerPin,LOW);
   delayMicroseconds(delayAmount);
 }    
 delay(20);
}        

void loop() {
 if (digitalRead (enter) == HIGH) { //Run check process when "enter" is pressed
   if (digitalRead (53) == HIGH && digitalRead (51) == HIGH && digitalRead (49) == LOW && digitalRead (47) == LOW && digitalRead (45) == LOW) { //Checking the passcode
     digitalWrite(48, HIGH);
   }
   else { //Plays if passcode is incorrect
     beep(speakerPin, NOTE_C4, 500);
   }
 }
}    
)
I fixed one of my type declarations (48 is an input, not output).

It did NOT work as expected. What instead happened is my LED stayed on, and my piezo kept on buzzing (frequency: 262). I have no idea if its the code or my circuitry, so I have created a file in Fritzing so someone could try to help me. (Fritzing file in the attachments). Also, you may notice I have a resistor coming from the 3.3v pin into the DIP switch. That was because I was worried about short circuitry. I don't know if I will need it or not.
Title: Re: Error with tone library
Post by: nickgammon on Sep 22, 2013, 11:42 pm
How is this all wired up?

http://www.gammon.com.au/switches
Title: Re: Error with tone library
Post by: Strontium on Sep 23, 2013, 12:04 am

How is this all wired up?

http://www.gammon.com.au/switches

I'll start wiring that all up. I never knew that can happen.
Title: Re: Error with tone library
Post by: Strontium on Sep 23, 2013, 12:28 am
Alright, so I have added pull down resistors to all my switches (including the button). Now I am getting some very strange behavior.

When I first start it up, it plays a very high pitched noise until I press my "enter" button. Then, it plays the correct note for the correct duration.

My LED is staying on the WHOLE time, and I don't really know why.

When I configure my switches (where the passcode is entered), then press the "enter" button, it does nothing, whether the passcode is wrong or not.

I'll post the new version once I get the Fritzing file edited.
Title: Re: Error with tone library
Post by: Strontium on Sep 23, 2013, 12:34 am
Alright, new Fritzing file with the pull-down resistors. (In attachments)
Title: Re: Error with tone library
Post by: nickgammon on Sep 23, 2013, 12:40 am
Code: [Select]

  pinMode(53, INPUT);
  pinMode(51, INPUT);
  pinMode(49, INPUT);
  pinMode(47, INPUT);
  pinMode(45, INPUT);
  pinMode(52, OUTPUT);
  pinMode(50, OUTPUT);
  pinMode(48, INPUT);


How about some meaningful constants here, like LED for the LED, and so on? This is just guesswork looking at this.
Title: Re: Error with tone library
Post by: nickgammon on Sep 23, 2013, 12:41 am
Code: [Select]

#define enter 48
...
  if (digitalRead (enter) == HIGH) { //Run check process when "enter" is pressed
   ...
      digitalWrite(48, HIGH);



If pin 48, which is an input, is HIGH, write HIGH to it. ?

This is why you need symbols and not sprinkle numbers all through your code.
Title: Re: Error with tone library
Post by: Strontium on Sep 23, 2013, 01:01 am

Code: [Select]

#define enter 48
...
  if (digitalRead (enter) == HIGH) { //Run check process when "enter" is pressed
   ...
      digitalWrite(48, HIGH);



If pin 48, which is an input, is HIGH, write HIGH to it. ?

This is why you need symbols and not sprinkle numbers all through your code.


Me being a derp. That should have been the LED pin. I'll label my code and re-post it.

Code: [Select]

#define NOTE_C4  262
int speakerPin = 52;

void setup() {
  pinMode(53, INPUT); //DIP posistion 1
  pinMode(51, INPUT); //DIP position 2
  pinMode(49, INPUT); //DIP position 3
  pinMode(47, INPUT); //DIP position 4
  pinMode(45, INPUT); //DIP position 5
  pinMode(52, OUTPUT); //Piezo Buzzer
  pinMode(50, OUTPUT); //LED
  pinMode(48, INPUT); //"enter" button

}

void beep (unsigned char speakerPin, int frequencyInHertz, long timeInMilliseconds)  //code for working out the rate at which each note plays and the frequency.
{
  int x;     
  long delayAmount = (long)(1000000/frequencyInHertz);
  long loopTime = (long)((timeInMilliseconds*1000)/(delayAmount*2));
  for (x=0;x<loopTime;x++)   
  {   
    digitalWrite(speakerPin,HIGH);
    delayMicroseconds(delayAmount);
    digitalWrite(speakerPin,LOW);
    delayMicroseconds(delayAmount);
  }   
  delay(20);
}       

void loop() {
  if (digitalRead (48) == HIGH) { //Run check process when "enter" is pressed
    if (digitalRead (53) == HIGH && digitalRead (51) == HIGH && digitalRead (49) == LOW && digitalRead (47) == LOW && digitalRead (45) == LOW) { //Checking the passcode
      digitalWrite(50, HIGH); //Turn on LED
      delay(5000);
      digitalWrite(50, LOW); //Turn off LED
    }
    else {
      beep(speakerPin, NOTE_C4, 500); //Play tone
    }
  }
}   


That may have been part of the issue. I'll try it now.
Title: Re: Error with tone library
Post by: Strontium on Sep 23, 2013, 01:04 am
Yay! It works now. However, when I start it (and restart it) I am greeted with a high pitches buzz and keeps the LED on until I press enter. I think there is an easy fix for this, though.

I feel like such an idiot.

EDIT: Found a fix. It seems that after a pins type is declared, it sets it to high (for OUTPUTS). So I made it so once setup is complete, it sets them to LOW.
Code: [Select]

void setup() {
  pinMode(53, INPUT); //DIP posistion 1
  pinMode(51, INPUT); //DIP position 2
  pinMode(49, INPUT); //DIP position 3
  pinMode(47, INPUT); //DIP position 4
  pinMode(45, INPUT); //DIP position 5
  pinMode(52, OUTPUT); //Piezo Buzzer
  pinMode(50, OUTPUT); //LED
  pinMode(48, INPUT); //"enter" button
  digitalWrite(50, LOW);
  digitalWrite(52, LOW);
}
Title: Re: Error with tone library
Post by: nickgammon on Sep 23, 2013, 07:33 am
Code: [Select]

  pinMode(53, INPUT); //DIP posistion 1
  pinMode(51, INPUT); //DIP position 2


I didn't mean with comments. I meant (like you did for "enter")...

Code: [Select]

const byte DIP_SWITCH_1 = 53;
const byte DIP_SWITCH_2 = 51;

...

  pinMode(DIP_SWITCH_1, INPUT);
  pinMode(DIP_SWITCH_2, INPUT);

...

if (digitalRead (DIP_SWITCH_1) == HIGH && digitalRead (DIP_SWITCH_2) == HIGH && ...


And so on.


Whilst comments are nice, they can say anything. Proper constants actually show what the code is doing.