Hello, I am trying to run a simple motor test with my Arduino board. I have installed the Adafruit BusIO library but I don’t know why I’m getting this error:
> Executing task in folder my_Motor: C:\Users\DDS\.platformio\penv\Scripts\platformio.exe run <
Processing megaatmega2560 (platform: atmelavr; framework: arduino; board: megaatmega2560)
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/megaatmega2560.html
PLATFORM: Atmel AVR 2.2.0 > Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)
HARDWARE: ATMEGA2560 16MHz, 8KB RAM, 248KB 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 15 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Adafruit Motor Shield V2 Library> 1.0.9
| |-- <Adafruit ILI9341> 1.5.6
| | |-- <Adafruit GFX Library> 1.9.0
| | | |-- <Adafruit BusIO> 1.3.3
| | | | |-- <Wire> 1.0
| | | |-- <Wire> 1.0
| | |-- <Adafruit STMPE610> 1.1.2
| | | |-- <Wire> 1.0
| | |-- <Adafruit TouchScreen> 1.1.0
| |-- <Adafruit GFX Library> 1.9.0
| | |-- <Adafruit BusIO> 1.3.3
| | | |-- <Wire> 1.0
| | |-- <Wire> 1.0
| |-- <Adafruit SSD1306> 2.3.1
| | |-- <Adafruit GFX Library> 1.9.0
| | | |-- <Adafruit BusIO> 1.3.3
| | | | |-- <Wire> 1.0
| | | |-- <Wire> 1.0
| | |-- <Wire> 1.0
| |-- <AccelStepper> 1.59
| |-- <Servo> 1.1.6
| |-- <Wire> 1.0
|-- <Wire> 1.0
Building in release mode
Compiling .pio\build\megaatmega2560\libd39\Adafruit BusIO\Adafruit_BusIO_Register.cpp.o
Compiling .pio\build\megaatmega2560\libd39\Adafruit BusIO\Adafruit_SPIDevice.cpp.o
Compiling .pio\build\megaatmega2560\lib4ca\Adafruit GFX Library\Adafruit_GFX.cpp.o
Compiling .pio\build\megaatmega2560\lib4ca\Adafruit GFX Library\Adafruit_MonoOLED.cpp.o
In file included from C:\Users\DDS\.platformio\lib\Adafruit BusIO\Adafruit_SPIDevice.cpp:1:0:
C:\Users\DDS\.platformio\lib\Adafruit BusIO/Adafruit_SPIDevice.h:1:17: fatal error: SPI.h: No such file or directory
*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:SPI.h"
* Web > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************
compilation terminated.
In file included from C:\Users\DDS\.platformio\lib\Adafruit BusIO/Adafruit_BusIO_Register.h:2:0,
from C:\Users\DDS\.platformio\lib\Adafruit BusIO\Adafruit_BusIO_Register.cpp:1:
C:\Users\DDS\.platformio\lib\Adafruit BusIO/Adafruit_SPIDevice.h:1:17: fatal error: SPI.h: No such file or directory
*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:SPI.h"
* Web > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************
compilation terminated.
In file included from C:\Users\DDS\.platformio\lib\Adafruit GFX Library\Adafruit_MonoOLED.h:31:0,
from C:\Users\DDS\.platformio\lib\Adafruit GFX Library\Adafruit_MonoOLED.cpp:20:
C:\Users\DDS\.platformio\lib\Adafruit BusIO/Adafruit_SPIDevice.h:1:17: fatal error: SPI.h: No such file or directory
*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:SPI.h"
* Web > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************
compilation terminated.
*** [.pio\build\megaatmega2560\libd39\Adafruit BusIO\Adafruit_SPIDevice.cpp.o] Error 1
*** [.pio\build\megaatmega2560\libd39\Adafruit BusIO\Adafruit_BusIO_Register.cpp.o] Error 1
*** [.pio\build\megaatmega2560\lib4ca\Adafruit GFX Library\Adafruit_MonoOLED.cpp.o] Error 1
================================================================ [FAILED] Took 3.18 seconds ================================================================
The terminal process "C:\Users\DDS\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
Here is my simple code:
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);
// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
// You can also make another motor on port M2
//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Adafruit Motorshield v2 - DC Motor test!");
AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz
// Set the speed to start, from 0 (off) to 255 (max speed)
myMotor->setSpeed(150);
myMotor->run(FORWARD);
// turn on motor
myMotor->run(RELEASE);
}
void loop()
{
uint8_t i;
Serial.print("tick");
myMotor->run(FORWARD);
for (i=0; i<255; i++)
{
myMotor->setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--)
{
myMotor->setSpeed(i);
delay(10);
}
}
How can get ride of this error?
Thank you
Joe