About UsbAct beta
Arduino mega 用のテストアプリです。
以下のコードをArduino megaに書き込み、Phone(Android os)とArduino megaをUSBで繋いだ際に使用します。
機能
Arduinoの13番にLEDランプを繋げ、アプリのボタンを押すと、LEDランプが点灯します。
-------------------------------------------
#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>
AndroidAccessory acc("saibakho",
"UsbAct",
"UsbAct Arduino Board",
"1.0",
"https://play.google.com/store/apps/details?id=usb.act",
"0000000012345678");
int led = 13;
void setup()
{
Serial.begin(115200);
acc.powerOn();
pinMode(led, OUTPUT);
}
void loop()
{
byte receiveM[1];
if (acc.isConnected()) {
int len = acc.read(receiveM, sizeof(receiveM), 1);
if(len > 0&&receiveM[0]=='a'){
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
}
}
delay(10);
}
------------------------------------------- This is a test app for Arduino mega.
It is used when writing to Arduino mega the following code, it was connected via USB to the Arduino mega Phone (Android os).
Function
And connect the LED lamp on 13th of Arduino, you press the button on the app, LED lamp is lit.
-------------------------------------------
# Include
# Include
# Include
AndroidAccessory acc ("saibakho",
"UsbAct",
"UsbAct Arduino Board",
"1.0",
"Https://play.google.com/store/apps/details?id=usb.act",
"0000000012345678");
int led = 13;
void setup ()
{
Serial.begin (115200);
acc.powerOn ();
pinMode (led, OUTPUT);
}
void loop ()
{
byte receiveM [1];
if (acc.isConnected ()) {
int len = acc.read (receiveM, sizeof (receiveM), 1);
if (len> 0 && receiveM [0] == 'a') {
digitalWrite (led, HIGH);
delay (1000);
digitalWrite (led, LOW);
delay (1000);
}
}
delay (10);
}
-------------------------------------------