#include <EEPROM.h>
int sensorPin = 4;
long result = 0;
void setup()
{
Serial.begin(9600);
Serial.println("start");
for (int i=0; i < 13; i++){
Serial.println(RCtime(sensorPin) );
delay(1);
EEPROM.write(i, RCtime(sensorPin));
delay(15000);
}
}
void loop()
{
}
long RCtime(int sensPin){
long result = 0;
pinMode(sensPin, OUTPUT); // make pin OUTPUT
digitalWrite(sensPin, HIGH); // make pin HIGH to discharge capacitor - study the schematic
delay(1); // wait a ms to make sure cap is discharged
pinMode(sensPin, INPUT); // turn pin into an input and time till pin goes low
digitalWrite(sensPin, LOW); // turn pullups off - or it won't work
while(digitalRead(sensPin)){ // wait for pin to go low
result++;
}
return result;
}
int sensorPin = 4;
long result = 0;
void setup()
{
Serial.begin(9600);
Serial.println("start");
for (int i=0; i < 13; i++){
Serial.println(RCtime(sensorPin) );
delay(1);
EEPROM.write(i, RCtime(sensorPin));
delay(15000);
}
}
void loop()
{
}
long RCtime(int sensPin){
long result = 0;
pinMode(sensPin, OUTPUT); // make pin OUTPUT
digitalWrite(sensPin, HIGH); // make pin HIGH to discharge capacitor - study the schematic
delay(1); // wait a ms to make sure cap is discharged
pinMode(sensPin, INPUT); // turn pin into an input and time till pin goes low
digitalWrite(sensPin, LOW); // turn pullups off - or it won't work
while(digitalRead(sensPin)){ // wait for pin to go low
result++;
}
return result;
}
#include
ReplyDeleteint sensorPin = 4;
long result = 0;
int RC = 0;
void setup()
{
Serial.begin(9600);
Serial.println("start");
}
void loop()
{
for (int i=0; i < 13; i++){
delay(1);
Serial.println(RCtime(sensorPin));
if(result > 255){
RC = 255;
}
else{
RC = byte(result);
}
Serial.println(RC);
EEPROM.write(i, RC);
delay(2000);
}
while(1){}
}
long RCtime(int sensPin){
long result = 0;
pinMode(sensPin, OUTPUT); // make pin OUTPUT
digitalWrite(sensPin, HIGH); // make pin HIGH to discharge capacitor - study the schematic
delay(1); // wait a ms to make sure cap is discharged
pinMode(sensPin, INPUT); // turn pin into an input and time till pin goes low
digitalWrite(sensPin, LOW); // turn pullups off - or it won't work
while(digitalRead(sensPin)){ // wait for pin to go low
result++;
}
return result;
}