Skip to content

Instantly share code, notes, and snippets.

@tommyjtl
Created August 19, 2017 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommyjtl/14bb3337ad4cee2c75966ce176082314 to your computer and use it in GitHub Desktop.
Save tommyjtl/14bb3337ad4cee2c75966ce176082314 to your computer and use it in GitHub Desktop.
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR
#endif
#define PIN 6
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(5, 5, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);
int beepPin = 7;
int ethanolPin = A0;
int potPin = A3;
void setup() {
matrix.begin();
matrix.setBrightness(15);
pinMode(ethanolPin, INPUT);
pinMode(potPin, INPUT);
pinMode(beepPin, OUTPUT);
}
void loop() {
int ethanolVal = analogRead(ethanolPin);
int potVal = analogRead(potPin);
int threshold = map(potVal, 0, 1023, 300, 550);
matrix.fillScreen(15);
matrix.fillRect(0,0,5,5,matrix.Color(0,255,255));
if ( ethanolVal > threshold ) {
tone(beepPin, 988, 20);
noTone(beepPin);
matrix.fillScreen(0);
matrix.drawRect(0,0,5,5,matrix.Color(255,0,0));
matrix.drawLine(0,0,4,4,matrix.Color(255,0,0));
matrix.drawLine(4,0,0,4,matrix.Color(255,0,0));
matrix.setBrightness(40);
}
matrix.show();
Serial.println(ethanolVal);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment