Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_DC 6
#define OLED_CS 7
#define OLED_RESET 8
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
#define seconds 1000
int picCount = 0;
int cameraPin = 5; // use digital pin 5
int cameraPressMs = 100; // only press the button for 30ms
void setup() {
// initialise the screen
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC);
// set camera pin for output
pinMode(cameraPin, OUTPUT);
}
void takePic() {
digitalWrite(cameraPin, HIGH);
delay(cameraPressMs);
digitalWrite(cameraPin, LOW);
picCount++;
}
void printPicCount() {
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("pics: ");
display.print(picCount);
display.display();
}
void loop() {
printPicCount();
takePic();
delay(30 * seconds);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment