From: Advaith Menon Date: Fri, 3 Oct 2025 03:47:42 +0000 (-0400) Subject: Update 08-Hackerman.ino X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=62f11c0eac93989fb70efc21ca5e67b44b644e3b;p=gt-ece4180-lab02.git Update 08-Hackerman.ino --- diff --git a/08-Hackerman/08-Hackerman.ino b/08-Hackerman/08-Hackerman.ino index 74f966a..5b82a2f 100644 --- a/08-Hackerman/08-Hackerman.ino +++ b/08-Hackerman/08-Hackerman.ino @@ -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 +#include +#include + +#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; }