]> Devi Nivas Git - gt-ece4180-lab02.git/commitdiff
Update 08-Hackerman.ino
authorAdvaith Menon <advaith@gatech.edu>
Fri, 3 Oct 2025 03:47:42 +0000 (23:47 -0400)
committerGitHub Enterprise <github-noreply@oit.gatech.edu>
Fri, 3 Oct 2025 03:47:42 +0000 (23:47 -0400)
08-Hackerman/08-Hackerman.ino

index 74f966a4e2fe85eb6097ef342c3d3f2633e66ad8..5b82a2f2a4174a76b11916a1619464e50f2bb3f9 100644 (file)
@@ -1,6 +1,84 @@
+/**
+ * @file 08-Hackerman.ino
+ * @author Advaith Menon, Anish Gajula, Lila Phonekeo
+ * @version 2025.10.02
+ * @brief Code to LEGALLY hack into Diego's ESP32 by sending data over SPI pins.
+ */
+#include <Wire.h>
+#include <Adafruit_MPR121.h>
+#include <HardwareSerial.h>
+
+#ifndef _BV
+#define _BV(bit) (1 << (bit)) 
+#endif
+
+Adafruit_MPR121 cap = Adafruit_MPR121();
+
+#define SDA_PIN 5
+#define SCL_PIN 6
+
+// Keeps track of the last pins touched
+// so we know when buttons are 'released'
+uint16_t lasttouched = 0;
+uint16_t currtouched = 0;
+uint16_t touched = 0;
+
+HardwareSerial Fratta(1);
 
 void setup() {
+  delay(1000);
+  Serial.begin(9600);
+  while (!Serial);
+  Serial.println("MPR121 Autoconfiguration Test. (MPR121-AutoConfig.ino)");
+  
+  Serial.println("startup `Wire`");
+  Wire.begin(SDA_PIN, SCL_PIN);
+  Serial.println("startup `Wire` done.");
+  delay(100);
+  
+  Serial.println("cap.begin..");
+  if (!cap.begin(0x5A, &Wire)) {
+    Serial.println("MPR121 not found, check wiring?");
+    while (1);
+  }
+  Serial.println("MPR121 found!");
+  
+  delay(100);
+
+  Serial.println("Initial CDC/CDT values:");
+
+  cap.setAutoconfig(true);
+
+  Serial.println("After autoconfig CDC/CDT values:");
+  Fratta.begin(9600, SERIAL_8N1, 0, 1);
 }
 
 void loop() {
+  // Get the currently touched pads
+  currtouched = cap.touched();
+  for (uint8_t i=0; i<12; i++) {
+    // it if *is* touched and *wasnt* touched before, alert!
+    if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) {
+      Serial.print(i); Serial.print(" touched, ");
+      if (i == 10) {
+            Serial.print("Passcode is: ");
+            Serial.println(touched);
+            Fratta.println(touched);
+            touched = 0;
+            break;
+        }
+
+        if (i == 11) {
+            touched = touched / 10;
+            break;
+        }
+      touched = touched * 10 + i;
+      Serial.print("is: ");
+      Serial.println(touched);
+    }
+  }
+
+  // reset our state
+  lasttouched = currtouched;
 }