-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNano_MysticalOuijaBoardV4.ino
More file actions
193 lines (165 loc) · 10.2 KB
/
Copy pathNano_MysticalOuijaBoardV4.ino
File metadata and controls
193 lines (165 loc) · 10.2 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/* Arduino Nano Electric Mystical Ouija Board by LSSteele and GitHub CoPilot 02/16/2026
Modified: Planchette moves based on capacitance/resistance electrical impulses.
Added a trace-antenna to A7 to pick up any emf activity for random-seed movement.
Compiles and Works!
IMPROVED VERSION - Enhanced sensitivity and movement
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// Bitmap dimensions
#define OUIJA_WIDTH 128
#define OUIJA_HEIGHT 64
// Bitmap dimensions
#define OUIJA_WIDTH 128
#define OUIJA_HEIGHT 64
// 'Ouija 128x64', 128x64px
const unsigned char epd_bitmap_Ouija_128x64 [] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x18, 0xa3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0x9c, 0x7f, 0xff,
0xff, 0x08, 0x8d, 0x99, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0x93, 0x3f, 0xff,
0xff, 0x83, 0xcb, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x83, 0x1f, 0xff,
0xff, 0xc7, 0xc3, 0xc1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x03, 0x1f, 0xff,
0xff, 0xe7, 0xce, 0xb9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x13, 0x1f, 0xff,
0xff, 0xc3, 0x80, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x98, 0x3f, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xa1, 0x80, 0x81, 0x84, 0x6f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x81, 0x8c, 0xcd, 0x1f, 0xcc, 0x63, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xe1, 0x8c, 0xcb, 0xc3, 0x30, 0xc0, 0xe7, 0xe3, 0x1f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xcc, 0xcc, 0x43, 0xcf, 0x39, 0xcc, 0xe7, 0xe7, 0x21, 0xbf, 0xff, 0xff, 0xff,
0xff, 0xff, 0x88, 0xcf, 0xcc, 0x46, 0x47, 0x91, 0x8c, 0xe6, 0x66, 0x0f, 0x8f, 0xff, 0xff, 0xff,
0xff, 0xff, 0x8c, 0xcf, 0x44, 0xc0, 0x57, 0xef, 0xa8, 0x46, 0x46, 0x0f, 0x9f, 0xbf, 0xff, 0xff,
0xff, 0xef, 0xc0, 0x46, 0x41, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1c, 0x47, 0x1f, 0x8f, 0xff, 0xff,
0xff, 0x87, 0xe6, 0x21, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x3f, 0x0f, 0xff, 0xff,
0xff, 0xc1, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0x48, 0x3f, 0xff,
0xff, 0xd0, 0x27, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc4, 0xc0, 0x7f, 0xff,
0xff, 0xc6, 0x7f, 0xff, 0xff, 0x9f, 0x04, 0x02, 0x32, 0x19, 0xff, 0xff, 0xfc, 0xf8, 0xff, 0xff,
0xff, 0xcf, 0xff, 0xff, 0xbc, 0x06, 0x35, 0x9a, 0x77, 0x19, 0x89, 0xff, 0xff, 0xf1, 0xff, 0xff,
0xff, 0xcf, 0xff, 0xfe, 0x0e, 0x66, 0x07, 0x9e, 0x77, 0x1b, 0x99, 0x99, 0xff, 0xe3, 0xff, 0xff,
0xff, 0xff, 0xfc, 0x0c, 0xc6, 0x0f, 0xe3, 0x9e, 0x77, 0x97, 0x81, 0x38, 0x4f, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfc, 0x64, 0xe2, 0x66, 0x33, 0x8f, 0x27, 0x8f, 0x80, 0x7c, 0x0c, 0xff, 0xff, 0xff,
0xff, 0xfe, 0x06, 0x64, 0x66, 0x31, 0x0f, 0xff, 0xdf, 0xcf, 0xc8, 0xfc, 0x3c, 0x7f, 0xff, 0xff,
0xff, 0xfe, 0x63, 0x0e, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdd, 0xf8, 0x7c, 0x43, 0xff, 0xff,
0xff, 0xce, 0x73, 0x1f, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe2, 0x3e, 0x1f, 0x7f, 0xff,
0xff, 0xe6, 0x33, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x1c, 0x7e, 0x1f, 0xff,
0xf8, 0x03, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0x87, 0xff,
0xfe, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xf0, 0x07, 0xff,
0xff, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe1, 0xff, 0xff,
0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xbf, 0xff,
0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf8, 0xe0, 0x60, 0x7c, 0x30, 0x1c, 0x10, 0x0c, 0x18, 0x1e, 0x07, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfc, 0x46, 0x66, 0x38, 0x72, 0x39, 0x90, 0x08, 0x88, 0x8c, 0x63, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfc, 0xec, 0x66, 0x60, 0x70, 0x70, 0x1f, 0x18, 0x18, 0x84, 0x61, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfc, 0xf0, 0xf0, 0x44, 0x13, 0x10, 0x8c, 0x78, 0x08, 0x00, 0x61, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfc, 0x63, 0xe6, 0x00, 0x13, 0x91, 0x8c, 0x71, 0x8c, 0x8c, 0x63, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf8, 0x40, 0x24, 0x7c, 0x31, 0x18, 0x1c, 0x38, 0x88, 0x8e, 0x07, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfb, 0x7e, 0x70, 0xf8, 0x7c, 0x7e, 0x3e, 0x7c, 0x3e, 0x7f, 0x9f, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x83, 0x87, 0x86, 0x07, 0xe0, 0x23, 0x10, 0x3f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x3b, 0x33, 0x33, 0x33, 0xf1, 0x31, 0x31, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0x26, 0x30, 0x31, 0x33, 0xf0, 0x38, 0x78, 0x7f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xfe, 0x32, 0x31, 0x31, 0x33, 0xf1, 0x18, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x33, 0x33, 0x32, 0x23, 0xf1, 0x18, 0xf1, 0x9f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x83, 0x87, 0x86, 0x0f, 0xf4, 0x78, 0x70, 0x1f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 1040)
const int epd_bitmap_allArray_LEN = 1;
const unsigned char* epd_bitmap_allArray[1] = {
epd_bitmap_Ouija_128x64
};
const int touchPins[4] = {A0, A1, A2, A3}; // 4 membrane switches
const int NUM_SENSORS = 4;
const int threshold = 2; // Lowered threshold for more sensitivity
int prevVals[NUM_SENSORS] = {0, 0, 0, 0}; // To store previous readings
int planchetteX = SCREEN_WIDTH / 2;
int planchetteY = SCREEN_HEIGHT / 2;
const int bitmapX = (SCREEN_WIDTH - OUIJA_WIDTH) / 2;
const int bitmapY = 0;
// Movement parameters - adjust these for different behavior
const int movementDivisor = 1; // Lower = more movement (was 4)
const int minMovement = 4; // Minimum pixels to move when threshold exceeded (was 2 now 4)
void setup() {
Serial.begin(9600); // For debugging
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
// Initialize previous values
for (int i = 0; i < NUM_SENSORS; i++) {
prevVals[i] = analogRead(touchPins[i]);
}
randomSeed(analogRead(A7)); // to pick up on any emf activity
Serial.println("Electric Ouija Board Initialized");
Serial.println("Touch sensors on A0-A3");
}
void loop() {
int currVals[NUM_SENSORS];
int deltas[NUM_SENSORS];
// Read the current values
for (int i = 0; i < NUM_SENSORS; i++) {
currVals[i] = analogRead(touchPins[i]);
// Calculate the change (delta)
deltas[i] = abs(currVals[i] - prevVals[i]);
prevVals[i] = currVals[i];
}
// Calculate total change across all sensors
int totalDelta = 0;
for (int i = 0; i < NUM_SENSORS; i++) {
totalDelta += deltas[i];
}
// Ignore changes if they are below the threshold
if (totalDelta > threshold) {
// Debug output
Serial.print("Deltas: ");
for (int i = 0; i < NUM_SENSORS; i++) {
Serial.print(deltas[i]);
Serial.print(" ");
}
Serial.print("| Total: ");
Serial.print(totalDelta);
// Introduce randomness weighted by the deltas
// Divide by 2 instead of 4 for more movement
int dx = random(-max(deltas[0] / movementDivisor, minMovement),
max(deltas[1] / movementDivisor, minMovement) + 1);
int dy = random(-max(deltas[2] / movementDivisor, minMovement),
max(deltas[3] / movementDivisor, minMovement) + 1);
Serial.print(" | dx: ");
Serial.print(dx);
Serial.print(" dy: ");
Serial.println(dy);
planchetteX += dx;
planchetteY += dy;
// Stay within bounds
planchetteX = constrain(planchetteX, bitmapX, bitmapX + OUIJA_WIDTH - 1);
planchetteY = constrain(planchetteY, bitmapY, bitmapY + OUIJA_HEIGHT - 1);
}
// Draw the Ouija board
display.clearDisplay();
display.drawBitmap(bitmapX, bitmapY, epd_bitmap_Ouija_128x64, OUIJA_WIDTH, OUIJA_HEIGHT, SSD1306_WHITE);
// Draw the planchette as a transparent ring
const int planchetteRadius = 8;
display.drawCircle(planchetteX, planchetteY, planchetteRadius, SSD1306_WHITE); // Outer circle
display.drawCircle(planchetteX, planchetteY, planchetteRadius - 2, SSD1306_BLACK); // Inner circle (erases center)
display.display();
delay(40); // Smooth animation
}