sketch_feb08b:16: error: expected unqualified-id before numeric constant 15

Was assigned to fixing an error in coding. Unfortunately, we have no idea what to do after a few attempts.

The code is here:

/**
2 * Copyright (c) 2015 by http://www.electrominds.com
3 * Simple Arduio Theremin "Theremino" Project
4 * Project URL: ElectroMinds.com
5 *
6 * This file is free software; you can redistribute it and/or modify
7 * it under the terms of either the GNU General Public License version 2
8 * or the GNU Lesser General Public License version 2.1, both as
9 * published by the Free Software Foundation.
10 *
11 * Required libraries:
12 * NewPing: Google Code Archive - Long-term storage for Google Code Project Hosting.
13 * toneAC: Google Code Archive - Long-term storage for Google Code Project Hosting.
14 */
15
16 include <NewPing.h>
17 include <toneAC.h>
18
19 define DEBUG false // Set to true to enable Serial debug
20 define TONE_PIN 8
21 define TONE_VOLUME 10 // 1-20
22 define TRIGGER_PIN 12 // Board pin tied to trigger pin on the ultrasonic sensor.
23 define ECHO_PIN 11 // Board pin tied to echo pin on the ultrasonic sensor.
24 define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
25
26 NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
27
28 void setup()
29 if (DEBUG) {
30 Serial.begin(115200);
31 Serial.println("Theremino starting");
32 }
33 }
35 void loop() {
36 delay(30); // Wait 30ms between pings (about 33 pings/sec). 29ms should be the shortest delay between pings.
37 unsigned long uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
38
39 if (DEBUG) Serial.println(uS);
40
41 if (uS > 2000) { // Range is about 0-30 cm from sensor
42 toneAC(0); // Turn sound off when not in range
43 if (DEBUG) Serial.println("No tone");
44 } else {
45 int freq = 2000 - uS / 1.5; // Get sound frequency
46 toneAC(freq, TONE_VOLUME); // Play it!
47 if (DEBUG) Serial.println(freq);
48 }
49 }

Don't post line numbers with your code. That just makes it more difficult for us to compile it.

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn't show the posting toolbar then you can just manually add the code tags:
[code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.

When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here USING CODE TAGS (</> button on the toolbar).

(deleted)

Hi

The error your seeing is caused by the line numbers. The reason it flags 15 is that the line number for the first line is missing and the line starts with the character sequence /* The compiler treats this as the start of a block quote and ignores all text until it sees */ at the end of line 14.

In order to get the sketch to compile you need to remove all line numbers.

There is a second error on line 28. There should be an opening brace { at the end of the line to encapsulate the lines of code (29 - 33) that make up the setup() function.

Hope this helps

Ian