|
A Few Words On Technical Aspects
The 9 installations:
We were rebuilding 9 basic versions of the Arduino.
We decided to to the programming of the chips on a different board, so we neither used an ISP header, nor a serial converter.
Additionally we added four opto-insulators (4N35) with connectors to switch the 4 contacts of the remote controls (forward, backward, left and right).
We also added a light dependent resistor as an on-off trigger sensor, to check if the spotlight above the board is on or off. We also added a variable resistor to this sensor, to be able to adjust the sensitivity with a screwdriver.
And we added a led to be able to see if the board is working.
Partslist:
1 DIP 28 Header
1 Atmega8
1 16 MHz crystal
2 22pf capacitors (for the crystal)
5 220 Ohm resistors (for the optoinsulators and the led)
1 10k Ohm resistor (for pulling the reset pin high)
4 4N35
1 10k Ohm ldr
1 variable resistor in the same range as the ldr
1 9V battery clip
1 7805 voltage regulator
1 1myF capacitor
1 10myF capacitor
1 circuit board
We used the Arduino IDE for programming and and compiling and the Atmel MKII to burn the chips on a self made board with an ISP.
/* 27MHz
jonas halfmeyer/daniel wessolek
class 06 C0mmunication
*/
int ledPin = 13;
int ldrPin = 5; // select the input pin for the ldr
int left = 11; // opto
int right = 12; // opto
int ff = 9; // opto
int rew = 10; // opto
int ldrThreshold = 512; //set threshold for the lightvalue here & physically with the poti...
int val = 0; // variable to store the value coming from the sensor
int counter = 0;
boolean checkLightCommand()
{
val = analogRead(ldrPin);
if (val > ldrThreshold) return true;
else return false;
}
void trigger(int who, int msec)
{
digitalWrite(who, HIGH);
delay(msec);
digitalWrite(who, LOW);
}
void go()
{
//YOUR CODE GOES HERE
}
void setup() {
pinMode(left, OUTPUT); // declare the optoPins as OUTPUTs
pinMode(right, OUTPUT);
pinMode(ff, OUTPUT);
pinMode(rew, OUTPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (checkLightCommand()) go(); //Check if there is a spotlight shining on the LDR
else {digitalWrite(ledPin, LOW);}
delay(1000); // stop the program for some time
}
the 10th element:
We bought 2 prefabricated relais board with 5 relais each. The relais were 12 V. These were meant to switch the 10 spotlights. Then we had 9 ldr's for the interface box.
So we somehow needed 9 analog inputs and 10 digital outputs. The first attempt was to solve it with two connected Arduinos. There were timing issues so we switched to using one Arduino and an analog 16 channel multiplexer (CD4067B) wich we had to cut down to 8 channels to have enough digital outs for the relais (through two ULN2803A) so one went separately through the Arduino analog in.
The construction behaved strangely each time we installed it in the hight of four meters, and we figured out that it was the external power supply. It seems to be an common error of the Arduino NG, we changed one resistor of the Arduino NG and then it worked...
/*_27 MHz
Masterboard
*/
int interface = 13;
int inhibit = 3;
int lights[9] = { 8, 7, 6, 5, 4, 12, 11, 10, 9 }; //{ 9, 8, 10, 11, 12, 4, 5, 6, 7 };
int lightState[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int oldLightState[9] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
int triggeredLightState[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int treshold = 512;
int val = 0;
int val2 = 0;
int arrayLength = 9;
int changebit = 0;
//int CONTROLpin1 = 3;
int CONTROLpin2 = 2;
int CONTROLpin3 = 1;
int CONTROLpin4 = 0;
void go()
{
digitalWrite(interface, HIGH);
delay(2000);
for (int i=0; i< arrayLength; i++) //fill stateArray
{
digitalWrite(inhibit, HIGH);
//digitalWrite(CONTROLpin1, (i&15)>>3);//bit4
digitalWrite(CONTROLpin2, (i&7)>>2);//bit3
digitalWrite(CONTROLpin3, (i&3)>>1);//bit2
digitalWrite(CONTROLpin4, (i&1) );//bit1
delay(2);
digitalWrite(inhibit, LOW);
delay(2);
val = analogRead(0);
if (i==8) val = analogRead(5);
if (val > treshold) {lightState[i] = 1;}
else {lightState[i] = 0;}
}
val = 0;
val2 = 0;
for (int i=0; i<arrayLength; i++) //compare to the last one and the triggered one
{
if (triggeredLightState[i] == lightState[i]) val2++; //identical to the last one?
if (oldLightState[i] != lightState[i]) val=1; //difference?
}
changebit=1;
if (val2==9)
{
changebit=0;
}
if ((val==0) && (changebit==1)) //go
{
for (int i=0; i<arrayLength; i++) //copy
{
triggeredLightState[i]=lightState[i];
}
digitalWrite(interface, LOW);
for (int i=0; i<arrayLength; i++) //switch the lights
{
if (lightState[i] == 1) digitalWrite(lights[i], HIGH);
}
for (int i=0; i<3; i++) //pause 1 min
{
delay(30000);
}
digitalWrite(interface, HIGH);
for (int i=0; i<arrayLength; i++) //reset
{
oldLightState[i]=0;
digitalWrite(lights[i], LOW);
}
}
for (int i=0; i<arrayLength; i++) //copy
{
oldLightState[i]=lightState[i];
}
}
void setup()
{
pinMode(inhibit, OUTPUT);
//pinMode(CONTROLpin1, OUTPUT);
pinMode(CONTROLpin2, OUTPUT);
pinMode(CONTROLpin3, OUTPUT);
pinMode(CONTROLpin4, OUTPUT);
pinMode(interface, OUTPUT);
for (int i=0; i<arrayLength; i++)
{
pinMode(lights[i], OUTPUT);
}
}
void loop()
{
go();
}
|
|
|