Compiling .pio\build\uno\src\main.cpp.o
src\main.cpp:111:1: error: 'Servo' does not name a type; did you mean 'Serial'?
Servo myservo;
^~~~~
Serial
src\main.cpp: In function 'void putWater()':
src\main.cpp:134:3: error: 'myservo' was not declared in this scope
myservo.write(380); // tell servo to go to position in variable 'pos'
^~~~~~~
src\main.cpp:134:3: note: suggested alternative: 'mySerial'
myservo.write(380); // tell servo to go to position in variable 'pos'
^~~~~~~
mySerial
src\main.cpp: In function 'void setup()':
src\main.cpp:217:3: error: 'myservo' was not declared in this scope
myservo.attach(12);
^~~~~~~
src\main.cpp:217:3: note: suggested alternative: 'mySerial'
myservo.attach(12);
^~~~~~~
mySerial
Compiling .pio\build\uno\FrameworkArduino\hooks.c.o
Compiling .pio\build\uno\FrameworkArduino\main.cpp.o
*** [.pio\build\uno\src\main.cpp.o] Error 1
Compiling .pio\build\uno\FrameworkArduino\new.cpp.o
======================================================================== [FAILED] Took 1.79 seconds ========================================================================The terminal process "C:\Users\Kaua Vitorio\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
> Executing task: C:\Users\Kaua Vitorio\.platformio\penv\Scripts\platformio.exe run <
Processing uno (platform: atmelavr; board: uno; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (3.3.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:
- framework-arduino-avr 5.1.0
- toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <SoftwareSerial> 1.0
Building in release mode
Compiling .pio\build\uno\src\main.cpp.o
src\main.cpp:111:1: error: 'Servo' does not name a type; did you mean 'Serial'?
Servo myservo;
^~~~~
Serial
src\main.cpp: In function 'void putWater()':
src\main.cpp:134:3: error: 'myservo' was not declared in this scope
myservo.write(380); // tell servo to go to position in variable 'pos'
^~~~~~~
src\main.cpp:134:3: note: suggested alternative: 'mySerial'
myservo.write(380); // tell servo to go to position in variable 'pos'
^~~~~~~
mySerial
src\main.cpp: In function 'void setup()':
src\main.cpp:217:3: error: 'myservo' was not declared in this scope
myservo.attach(12);
^~~~~~~
src\main.cpp:217:3: note: suggested alternative: 'mySerial'
myservo.attach(12);
^~~~~~~
mySerial
Compiling .pio\build\uno\FrameworkArduino\wiring.c.o
Compiling .pio\build\uno\FrameworkArduino\wiring_analog.c.o
Compiling .pio\build\uno\FrameworkArduino\wiring_digital.c.o
*** [.pio\build\uno\src\main.cpp.o] Error 1
My code
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <avr/wdt.h>
#include <SoftwareServo.h>
{#define notes}
SoftwareSerial mySerial(10, 11); // RX, TX
String command = ""; // Stores response of bluetooth device
// which simply allows \n between each
// response.
long int data;
int LED = 7;
int LEDGREEN = 6;
int LEDRED = 5;
int speakerPin = 4;
long int password1 = 92;
long int password2 = 79;
long int connectpass = 0;
char state = 0;
Servo myservo;
int pos = 0;
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 putWater(){
digitalWrite(LED, HIGH);
Serial.println("Puting Water ");
myservo.write(380); // tell servo to go to position in variable 'pos'
delay(2000);
myservo.write(0); // tell servo to go to position in variable 'pos'
delay(90);
digitalWrite(LED, LOW);
delay(305);
digitalWrite(LED, HIGH);
delay(305);
digitalWrite(LED, LOW);
delay(100);
Serial.println("Puting Water End ");
beep(speakerPin, NOTE_F5, 100);
delay(100);
beep(speakerPin, NOTE_G5, 100);
delay(100);
beep(speakerPin, NOTE_E5, 100);
delay(500);
}
void song() //here is where all the notes for the song are played.
{
beep(speakerPin, NOTE_D5, 100); // beep( -PIN OF SPEAKER-, -THE NOTE WANTING TO BE PLAYED-, -DURATION OF THE NOTE IN MILISECONDS- )
delay(80);
beep(speakerPin, NOTE_F5, 100);
delay(80);
beep(speakerPin, NOTE_D6, 200);
delay(250);
beep(speakerPin, NOTE_D5, 100);
delay(80);
beep(speakerPin, NOTE_F5, 100);
delay(80);
beep(speakerPin, NOTE_D6, 200);
delay(250);
beep(speakerPin, NOTE_E6, 200);
delay(200);
beep(speakerPin, NOTE_F6, 100);
delay(100);
beep(speakerPin, NOTE_E6, 100);
delay(80);
beep(speakerPin, NOTE_F6, 100);
delay(80);
beep(speakerPin, NOTE_E6, 100);
delay(80);
beep(speakerPin, NOTE_C6, 100);
delay(80);
beep(speakerPin, NOTE_A5, 100);
delay(300);
beep(speakerPin, NOTE_A5, 200);
delay(100);
beep(speakerPin, NOTE_D5, 200);
delay(100);
beep(speakerPin, NOTE_F5, 100);
delay(100);
beep(speakerPin, NOTE_G5, 100);
delay(100);
beep(speakerPin, NOTE_A5, 100);
delay(500);
beep(speakerPin, NOTE_A5, 200);
delay(100);
beep(speakerPin, NOTE_D5, 200);
delay(100);
beep(speakerPin, NOTE_F5, 100);
delay(100);
beep(speakerPin, NOTE_G5, 100);
delay(100);
beep(speakerPin, NOTE_E5, 100);
}
void setup()
{
wdt_disable();
pinMode(LED, OUTPUT);
pinMode(LEDGREEN, OUTPUT);
pinMode(LEDRED, OUTPUT);
pinMode(speakerPin , OUTPUT);
myservo.attach(12);
myservo.write(0);
//song();
digitalWrite(LED, LOW);
digitalWrite(LEDGREEN, LOW);
digitalWrite(LEDRED, HIGH);
// Open serial communications and wait for port to open:
Serial.begin(115200);
Serial.println("Bem Vindo!");
// SoftwareSerial "com port" data rate. JY-MCU v1.03 defaults to 9600.
mySerial.begin(9600);
}
void loop()
{
while (mySerial.available() != 0){
digitalWrite(LEDGREEN, LOW);
digitalWrite(LEDRED, HIGH);
}
while (mySerial.available() == 0);
digitalWrite(LEDGREEN, HIGH);
digitalWrite(LEDRED, LOW);
if(mySerial.available() > 0){
data = mySerial.parseInt();
}
delay(200);
if(data == password1){
putWater();
}
if(data == password2){
digitalWrite(LED, HIGH);
Serial.println("LED OFF ");
}
if(data == 00){
digitalWrite(LED, LOW);
Serial.println("LED OFF ");
digitalWrite(LEDGREEN, LOW);
digitalWrite(LEDRED, HIGH);
wdt_enable(WDTO_1S);
}
if(data == 01){
digitalWrite(LEDGREEN, HIGH);
digitalWrite(LEDRED, LOW);
beep(speakerPin, NOTE_C6, 100);
delay(80);
beep(speakerPin, NOTE_A5, 100);
delay(300);
}
// Read device output if available.
/*if (mySerial.available())
{
while(mySerial.available())
{ // While there is more to be read, keep reading.
command += (char)mySerial.read();
}
Serial.println(command);
command = ""; // No repeats
}
// Read user input if available.
if (Serial.available())
{
delay(10); // The DELAY!
mySerial.write(Serial.read());
} */
}// END loop()
```
Are you using the servo library as in the Arduino IDE? If so, the header file(s) are:
Servo.h
ServoTimers.h
I notice you are using SoftwareServo.h
â I had a search at A professional collaborative platform for embedded development ¡ PlatformIO and got no results when searching for that header.
The Servo
class is defined in the Servo.h
header file.
I notice you are using the watchdog with a 1 second timeout as well. I donât see anything in the code that resets the watchdog within one second. The chances are that you will end up resetting the board every second.
In fact putWater()
has a two second delay so your âputting of waterâ will cause the watchdog to reset the board half way through the delay(2000)
call!
You need to call wdt_reset()
often enough so that you never exceed the specified 1 second timeout.
EDIT: What are you actually using the watchdog for? You disable it in setup()
and enable it when you receive â00â in loop()
.
HTH
Cheers,
Norm.