initial commit
This commit is contained in:
33
electricity/measure/measure.ino
Normal file
33
electricity/measure/measure.ino
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Into Robotics
|
||||
*/
|
||||
|
||||
const int lowerThreshold = 250;
|
||||
const int upperThreshold = 450;
|
||||
|
||||
const uint8_t analogPin = A0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
pinMode(analogPin, INPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
static bool state = LOW;
|
||||
static unsigned int counter = 0;
|
||||
int analogValue = analogRead(analogPin);
|
||||
if (state == HIGH) {
|
||||
if (analogValue < lowerThreshold) {
|
||||
state = LOW;
|
||||
counter++;
|
||||
Serial.println(counter);
|
||||
Serial.println("blykst");
|
||||
}
|
||||
} else { // state == LOW
|
||||
if (analogValue > upperThreshold) {
|
||||
state = HIGH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user