-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththequantumclock
More file actions
179 lines (134 loc) · 3.97 KB
/
thequantumclock
File metadata and controls
179 lines (134 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/* The Quantum Clock by xname
London 2011-12
Queen Mary - University of London
reality depends on the perspective of the observer
Thanks to Clock Tick Demonstration
By Matt Mets, completed in 2008 (public domain)
*/
// Board Setup
extern unsigned long timer0_overflow_count;
int clockA = 2; // Clock wires
int clockB = 3; // Order is not important.
int tickPin = clockA; // This keeps track of which clock pin should be fired next.
// Quantum Variables
int quanTime = 1000;
int schroedTime = 1500;
int heisenTime = 10;
// Sensors
int lightPin = A0; // photoresistor
int lightLevel = 0;
int presPin1 = A4; // proximity sensor1
int presPin2 = A5; // proximity sensor2
int presValue1 = 0;
int presValue2 = 0;
/*
"...quantum theory reminds us, as Bohr has put it,
of the old wisdom that when searching for harmony
in life one must never forget that in the drama
of existence we are ourselves both players and
spectators"
Heisenmberg: 1934
*/
// IO ports
void setup()
{
pinMode(clockA, OUTPUT);
pinMode(clockB, OUTPUT);
digitalWrite(clockA, LOW);
digitalWrite(clockB, LOW);
// light sensor
// pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
// Clock
void doTick() {
// senseLight();
// Energize the electromagnet in the wrong direction (at least in my clock)
digitalWrite(tickPin, HIGH);
delay(heisenTime);
digitalWrite(tickPin, LOW);
// Switch the direction so it will fire in the opposite way next time.
if (tickPin == clockA)
{
tickPin = clockB;
} else {
tickPin = clockA;
}
}
// Makes the clock flip
/* void doFlip() {
senseLight();
// Energize the electromagnet in the correct direction.
// It's ticking two seconds at a time, not sure why
digitalWrite(tickPin, HIGH);
delay(10);
digitalWrite(tickPin, LOW);
delay(10);
} */
void senseLight(){
lightLevel = analogRead(lightPin); //Read the lightlevel
// if you think you don't have time, maybe there's not enough light in your life
lightLevel = constrain(lightLevel, 0, 700);
if (lightLevel >= 600) {
quanTime = 500; // time goes faster when there is no light;
}
else if (lightLevel < 600 && lightLevel > 250){
quanTime = 1000;
}
else if (lightLevel < 250){
quanTime = 1500;
}
}
void sensePresence(){
presValue1 = analogRead(presPin1);
presValue2 = analogRead(presPin2);
if(presValue1 > 250){
heisenTime = 10;
}
else
heisenTime = 5;
if(presValue2 > 250){
/* doFlip(); */
heisenTime = 25;
}
/* else
doTick(); */
}
/*
"...the transition from the actual to the possible
takes place during the act of observation..."
Heisenberg: 1934
*/
// Main loop
void loop()
{
unsigned long startTime = millis();
unsigned long temp;
// Millis overflows after approx 50 days
// if you need corretion for this, check TimingRollover on arduino playground
while (true)
{
startTime += quanTime; // normal speed
// Wait until a second has passed.
while (startTime - millis() > 0) {
senseLight();
sensePresence();
} /// delay is no good here because it completely stops the processor
doTick();
Serial.println("Delay is HeisenTime");
Serial.println(heisenTime);
Serial.println("Tick frequency is quanTime");
Serial.println(quanTime);
Serial.println("Light level is lightLevel");
Serial.println(lightLevel);
Serial.println("Proximity sensor 1:");
Serial.println(presValue1);
Serial.println("Proximity sensor 2:");
Serial.println(presValue2);
}
}
/*
"What we cannot speak about
we must pass over in silence."
Ludwig Wittgenstein. Tractatus Logico-Philosophicus. 1922.
*/