#include <Arduino.h>
#include<Servo.h>
int pos=0;
Servo myservo;
void setup() {
// put your setup code here, to run once:
myservo.attach(8);
}
void loop() {
// put your main code here, to run repeatedly:
for(pos=0;pos<=180;pos++)
{
myservo.write(pos);
delay(15);
}
for(pos=180;pos>=0;pos--)
{
myservo.write(pos);
delay(15);
}
and for all other codes same exit status 1 error is shown
in function main
undefined refrence to init
undefined refrence to delay
Seems like the base Arduino framework has been corrupted. What platformio.ini are you using?
Also see Redirecting..., you need to write proper C++ code instead of Arduino INO code. Though that’s not yet the problem you’re having, first the upper must be solved.
#include <Arduino.h>
#include<Servo.h>
int pos=0;
Servo myservo;
void setup() {
// put your setup code here, to run once:
myservo.attach(8);
}
void loop() {
// put your main code here, to run repeatedly:
for(pos=0;pos<=180;pos++)
{
myservo.write(pos);
delay(15);
}
for(pos=180;pos>=0;pos--)
{
myservo.write(pos);
delay(15);
}
}
Builds without problems
>pio run
Processing nanoatmega328 (platform: atmelavr; board: nanoatmega328; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/nanoatmega328.html
PLATFORM: Atmel AVR 2.2.0 > Arduino Nano ATmega328
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 30KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES:
- framework-arduino-avr 5.0.0
- toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 9 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Servo> 1.1.6
Building in release mode
Compiling .pio\build\nanoatmega328\src\main.cpp.o
[..]
Compiling .pio\build\nanoatmega328\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\nanoatmega328\libFrameworkArduino.a
Indexing .pio\build\nanoatmega328\libFrameworkArduino.a
Linking .pio\build\nanoatmega328\firmware.elf
Building .pio\build\nanoatmega328\firmware.hex
Checking size .pio\build\nanoatmega328\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 2.5% (used 52 bytes from 2048 bytes)
Flash: [= ] 7.0% (used 2160 bytes from 30720 bytes)
===================== [SUCCESS] Took 2.80 seconds =====================
So it seems there is a problem with linker as compilation always stops at
Linking .pio\build\nanoatmega328\firmware.elf
And shows the undefined refrence error
Does the file C:\Users\91789\platformio\packages\framework-arduino-avr\cores\arduino\wiring.c exist and contains the functions void delay(unsigned long ms) and void init()?
No but it does contain
Wiring_analog
Wiring_digital
Wiring _private
Wiring_pulse
Wiring_pulse
Wiring_shift
And also my code compiles after deletion anf fresh installation of framework_avr but it happens only onetime and after that it starts showing same error