init
This commit is contained in:
commit
882b793cd2
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.pio
|
44
src/main.cpp
Normal file
44
src/main.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
//
|
||||
// Created by lukas on 10.04.20.
|
||||
//
|
||||
#include "Arduino.h"
|
||||
|
||||
#define MINVOLTAGE 2.5
|
||||
#define OHM 55
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
pinMode(8, OUTPUT);
|
||||
pinMode(A0, INPUT);
|
||||
|
||||
digitalWrite(8, LOW);
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
double all = 0;
|
||||
|
||||
void loop() {
|
||||
Serial.println();
|
||||
double voltage = (float) (analogRead(A0)) / 1024 * 5;
|
||||
if (voltage > MINVOLTAGE) {
|
||||
digitalWrite(8, HIGH);
|
||||
double current = voltage / OHM;
|
||||
double watt = current * voltage;
|
||||
double amphours = watt / 360;
|
||||
all += amphours;
|
||||
Serial.print(all * 1000, 5);
|
||||
Serial.print("mA/h already captured after - ");
|
||||
Serial.print(i * 10);
|
||||
Serial.println("s");
|
||||
i++;
|
||||
} else {
|
||||
digitalWrite(8, LOW);
|
||||
Serial.print("FINISHED voltage below minvoltage - ");
|
||||
Serial.print(all / 1000, 5);
|
||||
Serial.print("mA/h in - ");
|
||||
Serial.print(i * 10);
|
||||
Serial.println("s");
|
||||
}
|
||||
delay(10000);
|
||||
}
|
Loading…
Reference in New Issue
Block a user