HI.
I am working on Project 6 - Light Theremin
Once I created the code, and try to upload I get the following error
"Tone Not Declared in This Scope" and won't let me upload the program. The exact code is below:
int sensorValue;
int sensorLow = 1023;
int sensorHigh = 0;
const int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
while (millis() < 5000) {
sensorValue = analogRead(A0);
if (sensorValue > sensorHigh) {
sensorHigh = sensorValue;
}
if (sensorValue < sensorLow){
sensorLow = sensorValue;
}
}
digitalWrite(ledPin, LOW);
}
void loop() {
sensorValue = analogRead(A0);
int pitch = map(sensorValue,sensorLow,sensorHigh, 50, 4000);
tone(8,pitch,20);
delay(10);
}
The error information is as follows - Im using the online editor and using Arduino Due Native USB
/usr/local/bin/arduino-cli compile --fqbn arduino:sam:arduino_due_x --libraries /home/builder/opt/libraries/latest --build-cache-path /tmp --output-dir /tmp/069014772/build --build-path /tmp/arduino-build-F18E16C7BE23C2CA9C35509222C4B25D /tmp/069014772/sketch_may28a
Compiling sketch...
/home/builder/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10607 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/home/builder/.arduino15/packages/arduino/hardware/sam/1.6.12/system/libsam -I/home/builder/.arduino15/packages/arduino/hardware/sam/1.6.12/system/CMSIS/CMSIS/Include/ -I/home/builder/.arduino15/packages/arduino/hardware/sam/1.6.12/system/CMSIS/Device/ATMEL/ -I/home/builder/.arduino15/packages/arduino/hardware/sam/1.6.12/cores/arduino -I/home/builder/.arduino15/packages/arduino/hardware/sam/1.6.12/variants/arduino_due_x /tmp/arduino-build-F18E16C7BE23C2CA9C35509222C4B25D/sketch/sketch_may28a.ino.cpp -o /tmp/arduino-build-F18E16C7BE23C2CA9C35509222C4B25D/sketch/sketch_may28a.ino.cpp.o
/tmp/069014772/sketch_may28a/sketch_may28a.ino: In function 'void loop()':
/tmp/069014772/sketch_may28a/sketch_may28a.ino:23:18: error: 'tone' was not declared in this scope
tone(8,pitch,20);
^
Error during build: exit status 1
Any suggestions or thoughts on how to rectify this issue or errors that you can see. I have triple checked it so not sure how to fix.
Thanks