Skip to content

Commit cd80388

Browse files
committed
added binaries
1 parent 2c536aa commit cd80388

File tree

24 files changed

+1602
-0
lines changed

24 files changed

+1602
-0
lines changed

Android Binaries/DroidDroid.apk

17 KB
Binary file not shown.
2.44 MB
Binary file not shown.
2.44 MB
Binary file not shown.
2.44 MB
Binary file not shown.

Android Binaries/DroidTVLaunch.apk

2.44 MB
Binary file not shown.

Android Binaries/HomeAutomation.apk

33.2 KB
Binary file not shown.

Android Binaries/SoundTest.apk

15 KB
Binary file not shown.

Android Binaries/TempLoggerLaunch.apk

2.46 MB
Binary file not shown.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <Max3421e.h>
2+
#include <Usb.h>
3+
#include <AndroidAccessory.h>
4+
5+
AndroidAccessory acc("Simon Monk",
6+
"OpenAccessoryTest",
7+
"DemoKit Arduino Board",
8+
"1.0",
9+
"http://www.duinodroid.com",
10+
"0000000012345678");
11+
12+
void setup()
13+
{
14+
acc.powerOn();
15+
}
16+
17+
void loop()
18+
{
19+
byte msg[1];
20+
if (acc.isConnected())
21+
{
22+
int len = acc.read(msg, sizeof(msg), 1);
23+
if (len >= 1)
24+
{
25+
byte value = msg[0];
26+
sendMessage(value + 1);
27+
}
28+
}
29+
}
30+
31+
void sendMessage(int value)
32+
{
33+
if (acc.isConnected())
34+
{
35+
byte msg[2];
36+
msg[0] = value >> 8;
37+
msg[1] = value & 0xff;
38+
acc.write(msg, 2);
39+
}
40+
}
41+
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#include <MeetAndroid.h>
2+
3+
#define supplyVolts 6
4+
#define motorVolts 5
5+
#define baudRate 9600
6+
7+
MeetAndroid phone;
8+
9+
int left = 255; // midpoint
10+
int right = 255;
11+
12+
13+
int pwmLeftPin = 3;
14+
int pwmRightPin = 11;
15+
int directionLeftPin = 12;
16+
int directionRightPin = 13;
17+
18+
19+
void setup()
20+
{
21+
pinMode(pwmLeftPin, OUTPUT);
22+
pinMode(pwmRightPin, OUTPUT);
23+
pinMode(directionLeftPin, OUTPUT);
24+
pinMode(directionRightPin, OUTPUT);
25+
setMotors();
26+
27+
// use the baud rate your bluetooth module is configured to
28+
Serial.begin(baudRate);
29+
phone.registerFunction(setLeft, 'l');
30+
phone.registerFunction(setRight, 'r');
31+
}
32+
33+
void loop()
34+
{
35+
phone.receive();
36+
}
37+
38+
void setLeft(byte ignore, byte count)
39+
{
40+
int value = phone.getInt();
41+
left = value;
42+
setMotors();
43+
}
44+
45+
46+
void setRight(byte ignore, byte count)
47+
{
48+
int value = phone.getInt();
49+
right = value;
50+
setMotors();
51+
}
52+
53+
void setMotors()
54+
{
55+
int vLeft = abs(left - 255) * motorVolts / supplyVolts;
56+
int vRight = abs(right - 255) * motorVolts / supplyVolts;
57+
int dLeft = (left > 255);
58+
int dRight = (right > 255);
59+
if (vLeft < 50)
60+
{
61+
vLeft = 0;
62+
}
63+
if (vRight < 50)
64+
{
65+
vRight = 0;
66+
}
67+
analogWrite(pwmLeftPin, vLeft);
68+
analogWrite(pwmRightPin, vRight);
69+
digitalWrite(directionLeftPin, dLeft);
70+
digitalWrite(directionRightPin, dRight);
71+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
#define supplyVolts 6
3+
#define motorVolts 5
4+
5+
int pwmLeftPin = 3;
6+
int pwmRightPin = 11;
7+
int directionLeftPin = 12;
8+
int directionRightPin = 13;
9+
10+
11+
void setup()
12+
{
13+
pinMode(pwmLeftPin, OUTPUT);
14+
pinMode(pwmRightPin, OUTPUT);
15+
pinMode(directionLeftPin, OUTPUT);
16+
pinMode(directionRightPin, OUTPUT);
17+
setMotors(0, 0);
18+
}
19+
20+
void loop()
21+
{
22+
// forward
23+
setMotors(255, 255);
24+
delay(1000);
25+
// stop
26+
setMotors(0, 0);
27+
delay(1000);
28+
// back
29+
setMotors(-255, -255);
30+
delay(1000);
31+
// left
32+
setMotors(255, -255);
33+
delay(1000);
34+
// right
35+
setMotors(-255, 255);
36+
delay(1000);
37+
// stop
38+
setMotors(0, 0);
39+
delay(5000);
40+
}
41+
42+
void setMotors(int left, int right)
43+
{
44+
int vLeft = abs(left) * motorVolts / supplyVolts;
45+
int vRight = abs(right) * motorVolts / supplyVolts;
46+
int dLeft = (left > 0);
47+
int dRight = (right > 0);
48+
if (vLeft < 50)
49+
{
50+
vLeft = 0;
51+
}
52+
if (vRight < 50)
53+
{
54+
vRight = 0;
55+
}
56+
analogWrite(pwmLeftPin, vLeft);
57+
analogWrite(pwmRightPin, vRight);
58+
digitalWrite(directionLeftPin, dLeft);
59+
digitalWrite(directionRightPin, dRight);
60+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#include <Max3421e.h>
2+
#include <Usb.h>
3+
#include <AndroidAccessory.h>
4+
5+
int oscPin = 5;
6+
int op = 45;
7+
int minPulseSep = 50;
8+
long lastEventTime = 0;
9+
long lastTimerTime = 0;
10+
long timerPeriod = 500l;
11+
long lastLogTime = 0;
12+
long logPeriod = 60000l;
13+
int count = 0;
14+
15+
float smoothingFactor = 0.6;
16+
float instantaneousCPM = 0.0;
17+
float smoothedCPM = 0.0;
18+
19+
AndroidAccessory acc("Simon Monk",
20+
"DroidGeiger",
21+
"Geiger Counter Accessory",
22+
"1.0",
23+
"http://www.duinodroid.com/android",
24+
"0000000012345678");
25+
26+
void setup()
27+
{
28+
Serial.begin(9600);
29+
pinMode(oscPin, OUTPUT);
30+
analogWrite(oscPin, op);
31+
acc.powerOn();
32+
attachInterrupt(1, eventInterrupt, RISING);
33+
}
34+
35+
void loop()
36+
{
37+
if (acc.isConnected())
38+
{
39+
// every half, take the instantaneous reading and integrate
40+
// it with the average reading then send it
41+
long timeNow = millis();
42+
if (timeNow > (lastTimerTime + timerPeriod))
43+
{
44+
lastTimerTime = timeNow;
45+
integrateInstantReadingIntoSmooth();
46+
sendMessage('R', (int) smoothedCPM);
47+
}
48+
// every minute, send the accumulated minute total
49+
timeNow = millis();
50+
if (timeNow > (lastLogTime + logPeriod))
51+
{
52+
lastLogTime = timeNow;
53+
sendMessage('L', count);
54+
count = 0;
55+
}
56+
}
57+
delay(100);
58+
}
59+
60+
void eventInterrupt()
61+
{
62+
// set instantaneosReading
63+
calculateInstantCPM();
64+
count ++;
65+
sendMessage('E', 0);
66+
}
67+
68+
void calculateInstantCPM()
69+
{
70+
// instantaneous cpm = 60,000 / dt in mS
71+
long timeNow = millis();
72+
long dt = timeNow - lastEventTime;
73+
if (dt > minPulseSep)
74+
{
75+
instantaneousCPM = ((float)logPeriod) / dt;
76+
lastEventTime = timeNow;
77+
}
78+
}
79+
80+
void integrateInstantReadingIntoSmooth()
81+
{
82+
smoothedCPM = smoothedCPM * smoothingFactor + instantaneousCPM * (1 - smoothingFactor);
83+
}
84+
85+
void sendMessage(char flag, int cpm)
86+
{
87+
if (acc.isConnected())
88+
{
89+
byte msg[4];
90+
msg[0] = 0x04;
91+
msg[1] = (byte) flag;
92+
msg[2] = cpm >> 8;
93+
msg[3] = cpm & 0xff;
94+
acc.write(msg, 4);
95+
}
96+
}
97+
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#include <Max3421e.h>
2+
#include <Usb.h>
3+
#include <AndroidAccessory.h>
4+
5+
#define redPin 5
6+
#define greenPin 6
7+
#define bluePin 3
8+
9+
#define cycleTime 10
10+
11+
int red = 0;
12+
int green = 85;
13+
int blue = 170;
14+
15+
boolean randomMode = true;
16+
17+
18+
AndroidAccessory acc("Simon Monk",
19+
"DroidLightShow",
20+
"Light Show Accessory",
21+
"1.0",
22+
"http://www.duinodroid.com/android",
23+
"0000000012345678");
24+
25+
void setup()
26+
{
27+
Serial.begin(9600);
28+
pinMode(redPin, OUTPUT);
29+
pinMode(greenPin, OUTPUT);
30+
pinMode(bluePin, OUTPUT);
31+
acc.powerOn();
32+
}
33+
34+
void loop()
35+
{
36+
byte msg[3];
37+
if (acc.isConnected())
38+
{
39+
int len = acc.read(msg, sizeof(msg), 1);
40+
if (len > 2 && msg[0] == 1) // set red
41+
{
42+
red = msg[2];
43+
}
44+
if (len > 2 && msg[0] == 2) // set green
45+
{
46+
green = msg[2];
47+
}
48+
if (len > 2 && msg[0] == 3) // set blue
49+
{
50+
blue = msg[2];
51+
}
52+
if (len > 2 && msg[0] == 4) // test mode on
53+
{
54+
randomMode = true;
55+
}
56+
if (len > 2 && msg[0] == 5) // test mode off
57+
{
58+
randomMode = false;
59+
}
60+
}
61+
if (randomMode)
62+
{
63+
changeColors();
64+
}
65+
showColors();
66+
delay(cycleTime);
67+
}
68+
69+
void changeColors()
70+
{
71+
red ++;
72+
if (red > 255) red = 0;
73+
green ++;
74+
if (green > 255) green = 0;
75+
blue ++;
76+
if (blue > 255) blue = 0;
77+
}
78+
79+
void showColors()
80+
{
81+
analogWrite(redPin, red);
82+
analogWrite(greenPin, green);
83+
analogWrite(bluePin, blue);
84+
}

0 commit comments

Comments
 (0)