Hello,I`m trying to transfer some data from android to arduino,(my arduino is Arduino nuo R3, with a USB Host shield)
so i added two libraries:USB_Host_Shield and AndroidAccessory,and there is my code :
#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>
#include <WProgram.h>
#define redPin 13
#define cycleTime 10
boolean randomMode = true;
AndroidAccessory acc("Simon Monk",
"DroidLightShow",
"Light Show Accessory",
"1.0",
"http://www.duinodroid.com/android",
"0000000012345678");
void setup()
{
Serial.begin(9600);
pinMode(redPin, OUTPUT);
acc.powerOn();
}
void loop()
{
byte msg[3];
if (acc.isConnected())
{
acc.read(msg, sizeof(msg), 1);
if (msg[0] == 1) // set red
{
for(int i=0;i<5;i++){
digitalWrite(redPin,LOW);
delay(200);
digitalWrite(redPin,HIGH);
delay(200);
}
}
}
delay(cycleTime);
}
when I uploaded,there some errors.frist? the error is
In file included from sketch_aug23a.ino:1:
C:\Users\ACER\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:37:22: error: WProgram.h: No such file or directory
I changed #include"WProgram.h" to #include“Arduino.h”, maybe resolved the probelm,but there this a new .
C:\Users\ACER\Documents\Arduino\libraries\USB_Host_Shield\Max3421e.cpp: In static member function 'static void MAX3421E::setRST(uint8_t)':
C:\Users\ACER\Documents\Arduino\libraries\USB_Host_Shield\Max3421e.cpp:94: error: 'PD7' was not declared in this scope
C:\Users\ACER\Documents\Arduino\libraries\USB_Host_Shield\Max3421e.cpp:96: error: 'PD7' was not declared in this scope
C:\Users\ACER\Documents\Arduino\libraries\USB_Host_Shield\Max3421e.cpp: In static member function 'static uint8_t MAX3421E::readINT()':
C:\Users\ACER\Documents\Arduino\libraries\USB_Host_Shield\Max3421e.cpp:101: error: 'PB1' was not declared in this scope
C:\Users\ACER\Documents\Arduino\libraries\USB_Host_Shield\Max3421e.cpp: In static member function 'static void MAX3421E::pinInit()':
C:\Users\ACER\Documents\Arduino\libraries\USB_Host_Shield\Max3421e.cpp:113: error: 'PB1' was not declared in this scope
C:\Users\ACER\Documents\Arduino\libraries\USB_Host_Shield\Max3421e.cpp:114: error: 'PD7' was not declared in this scope
there is part of the Max3421e.cpp:
...
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
#define INT PB1
#define INT_PORT PORTB
#define INT_DDR DDRB
#define INT_PIN PINB
#define RST PD7
#define RST_PORT PORTD
#define RST_DDR DDRD
#define RST_PIN PIND
#define GPX PB0
#define GPX_PORT PORTB
#define GPX_DDR DDRB
#define GPX_PIN PINB
#endif
void MAX3421E::setRST(uint8_t val)
{
if (val == LOW)
RST_PORT &= ~_BV(RST);
else
RST_PORT |= _BV(RST);
}
...
(PD7 PB0 are Pins of the AtmeGa328p)
how to sovle this ?