Advertisement
Guest User

EMF OLED v0.99a

a guest
Jun 19th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Import required libraries
  2. #include <ArducamSSD1306.h>    // Modification of Adafruit_SSD1306 for ESP8266 compatibility
  3. #include <Adafruit_GFX.h>   // Needs a little change in original Adafruit library (See README.txt file)
  4. #include <Wire.h>           // For I2C Communication
  5.  
  6. // Declare Integers and Their Base values for EMF Magnitude
  7. int current = 1;
  8. int peak = 1;
  9.  
  10. // Pin definitions
  11. #define OLED_RESET  7  // Pin 7 -RESET digital signal
  12.  
  13. // Some I2C Shit
  14. ArducamSSD1306 display(OLED_RESET);
  15.  
  16.  
  17. void setup(void)
  18. {
  19.   // initialize digital pin LED_BUILTIN as an output. for checking loop.
  20.   pinMode(LED_BUILTIN, OUTPUT);
  21.  
  22.   // Start Serial
  23.   Serial.begin(115200);
  24.  
  25.   // SSD1306 Init
  26.   display.begin();  // Switch OLED
  27.   // Clear the buffer.
  28.   display.clearDisplay();
  29.   display.setTextSize(1);
  30.   display.setTextColor(WHITE);
  31.  
  32. }
  33.  
  34. void loop()
  35. {
  36.   // Title
  37.   display.setCursor(10,2);
  38.   display.println("EMF Detector v1:");
  39.  
  40.   // Divider Line
  41.   display.setCursor(10,15);
  42.   display.println("----------------");
  43.  
  44.   // Reading Display Current
  45.   display.setCursor(10,25);
  46.   display.println("Current: ");
  47.  
  48.   ///////////////////////////////////////////////
  49.   // Output Current Reading with Variable to LED
  50.   if(current>10)
  51.   {
  52.     current = 0;
  53.   }
  54.   else
  55.   {
  56.     current + 1;
  57.   }
  58.  
  59.   display.setCursor(80,25);
  60.   display.print(current);
  61.  
  62.   // Something gay is afoot in this shit.
  63.   ///////////////////////////////////////////////
  64.  
  65.   display.setCursor(10,45);
  66.   display.println("Peak: ");
  67.  
  68.   // Highest Reading Taken Appears Here as Variable on LED
  69.   display.setCursor(80,45);
  70.   //
  71.   //
  72.   display.print(peak);
  73.   //
  74.   //
  75.   //
  76.   //
  77.   // LED for Checking Loop
  78.   // LED On
  79.   digitalWrite(LED_BUILTIN, HIGH);
  80.   delay(1000);
  81.  
  82.   // LED Off
  83.   digitalWrite(LED_BUILTIN, LOW);
  84.  
  85.   // Pass This into LED Buffer
  86.   display.display();
  87.  
  88.   // Wait
  89.   delay(250);
  90.  
  91.   // Clear Buffer & Repeat
  92.   display.clearDisplay();
  93.  
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement