Skip to content

Commit 9c136d0

Browse files
committed
everything for stewart, max and jac
0 parents  commit 9c136d0

File tree

4 files changed

+186
-0
lines changed

4 files changed

+186
-0
lines changed

GOPR0001.JPG

4.99 MB
Loading

LEDhackPHX.ino

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
int time = 100;
2+
void setup()
3+
{
4+
pinMode(13, OUTPUT);
5+
pinMode(12, OUTPUT);
6+
pinMode(11, OUTPUT);
7+
pinMode(10, OUTPUT);
8+
pinMode(9, OUTPUT);
9+
pinMode(8, OUTPUT);
10+
pinMode(7, OUTPUT);
11+
pinMode(6, OUTPUT);
12+
pinMode(5, OUTPUT);
13+
pinMode(4, OUTPUT);
14+
pinMode(3, OUTPUT);
15+
pinMode(2, OUTPUT);
16+
pinMode(A0, OUTPUT);
17+
pinMode(A1, OUTPUT);
18+
pinMode(A2, OUTPUT);
19+
pinMode(A3, OUTPUT);
20+
}
21+
22+
void loop()
23+
{
24+
digitalWrite(13, HIGH);
25+
delay(time);
26+
digitalWrite(13, LOW);
27+
delay(time);
28+
digitalWrite(12, HIGH);
29+
delay(time);
30+
digitalWrite(12, LOW);
31+
delay(time);
32+
digitalWrite(11, HIGH);
33+
delay(time);
34+
digitalWrite(11, LOW);
35+
delay(time);
36+
digitalWrite(10, HIGH);
37+
delay(time);
38+
digitalWrite(10, LOW);
39+
delay(time);
40+
digitalWrite(9, HIGH);
41+
delay(time);
42+
digitalWrite(9, LOW);
43+
delay(time);
44+
digitalWrite(8, HIGH);
45+
delay(time);
46+
digitalWrite(8, LOW);
47+
delay(time);
48+
digitalWrite(7, HIGH);
49+
delay(time);
50+
digitalWrite(7, LOW);
51+
delay(time);
52+
digitalWrite(6, HIGH);
53+
delay(time);
54+
digitalWrite(6, LOW);
55+
delay(time);
56+
digitalWrite(5, HIGH);
57+
delay(time);
58+
digitalWrite(5, LOW);
59+
delay(time);
60+
digitalWrite(4, HIGH);
61+
delay(time);
62+
digitalWrite(4, LOW);
63+
delay(time);
64+
digitalWrite(3, HIGH);
65+
delay(time);
66+
digitalWrite(3, LOW);
67+
delay(time);
68+
digitalWrite(2, HIGH);
69+
delay(time);
70+
digitalWrite(2, LOW);
71+
delay(time);
72+
digitalWrite(A0, HIGH);
73+
delay(time);
74+
digitalWrite(A0, LOW);
75+
delay(time);
76+
digitalWrite(A1, HIGH);
77+
delay(time);
78+
digitalWrite(A1, LOW);
79+
delay(time);
80+
digitalWrite(A2, HIGH);
81+
delay(time);
82+
digitalWrite(A2, LOW);
83+
delay(time);
84+
digitalWrite(A3, HIGH);
85+
delay(time);
86+
digitalWrite(A3, LOW);
87+
delay(time);
88+
}

lightdog/lightdog.ino

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//Make sure the dip switches are turned ON, and none of your shields are using pins A0,A1,A2,A3 or D4
2+
3+
#include <Shieldbot.h> //includes the Shieldbot Library
4+
5+
Shieldbot shieldbot = Shieldbot(); //decares a Shieldbot object
6+
7+
#define ARR_LEN(x) (sizeof(x) / sizeof((x)[0]))
8+
9+
//#define DBGTEAM4
10+
11+
void setup(){
12+
Serial.begin(9600);//Begin serial comm for debugging
13+
shieldbot.setMaxSpeed(60,70);//255 is max, if one motor is faster than another, adjust values
14+
}
15+
16+
void loop()
17+
{
18+
int s[5];
19+
20+
s[4] = shieldbot.readS1();
21+
s[3] = shieldbot.readS2();
22+
s[2] = shieldbot.readS3();
23+
s[1] = shieldbot.readS4();
24+
s[0] = shieldbot.readS5();
25+
26+
#define ___ 255 // don't care
27+
#define ON_ HIGH // light
28+
#define OFF LOW // dark
29+
30+
#ifdef DBGTEAM4
31+
#define txt(x) ,x
32+
#else
33+
#define txt(x)
34+
#endif
35+
36+
// Table that defines the behavior of the motors, based on the
37+
// sensors. The entries in the table either have to match the sensors
38+
// exactly, or they can
39+
const struct lookup_t
40+
{
41+
int s[5];
42+
char lspeed, rspeed;
43+
#ifdef DBGTEAM4
44+
const char *desc;
45+
#endif
46+
} lookups[] =
47+
{
48+
{ { OFF, OFF, ON_, OFF, OFF }, 127, 127 txt("1 center") }, // 1 center light: straight ahead
49+
{ { OFF, ON_, OFF, ON_, OFF }, 127, 127 txt("2 center") }, // 2 center lights: straight ahead
50+
{ { OFF, ON_, ON_, ON_, OFF }, 127, 127 txt("3 center") }, // 3 center lights: straight ahead
51+
{ { ON_, ON_, ON_, ON_, ON_ }, 0, 0 txt("all lit") }, // All lit: stop, we don't know where to go
52+
{ { ON_, ON_, ON_, ___, OFF }, 0, 127 txt("3/4 left") }, // 3 or 4 left lights: soft left
53+
{ { OFF, ___, ON_, ON_, ON_ }, 127, 0 txt("3/4 right") }, // 3 or 4 right lights: soft right
54+
{ { OFF, ON_, ___, OFF, OFF }, 127, 0 txt("1/2 left") }, // 1 or 2 left lights: soft left
55+
{ { OFF, OFF, ___, ON_, OFF }, 0, 127 txt("1/2 right") }, // 1 or 2 right lights: soft right
56+
{ { ON_, ON_, OFF, OFF, OFF }, 0, 127 txt("2 left") }, // 2 left lights: soft left
57+
{ { OFF, OFF, OFF, ON_, ON_ }, 127, 0 txt("2 right") }, // 2 right lights: soft right
58+
{ { ON_, OFF, OFF, OFF, OFF }, -128, 127 txt("1 left") }, // 1 left light: hard left
59+
{ { OFF, OFF, OFF, OFF, ON_ }, 127, -128 txt("1 right") }, // 1 right light: hard right
60+
};
61+
62+
int found;
63+
for (unsigned lut = 0; lut < ARR_LEN(lookups); lut++)
64+
{
65+
const struct lookup_t *plookup = &lookups[lut];
66+
found = 1;
67+
68+
for (unsigned index = 0; (found) && (index < 5); index++)
69+
{
70+
int wanted = plookup->s[index];
71+
72+
if ( (wanted != ___) && (s[index] != wanted) )
73+
{
74+
found = 0;
75+
break;
76+
}
77+
}
78+
79+
if (found)
80+
{
81+
#ifdef DBGTEAM4
82+
Serial.println(plookup->desc);
83+
#endif
84+
shieldbot.drive(plookup->lspeed, plookup->rspeed);
85+
break;
86+
}
87+
}
88+
89+
if (!found)
90+
{
91+
#ifdef DBGTEAM4
92+
Serial.println("???");
93+
#endif
94+
shieldbot.drive(0, 0);
95+
delay(100);
96+
}
97+
}
98+

team4_dog.pdf

10.7 MB
Binary file not shown.

0 commit comments

Comments
 (0)