checking temp and lighting
Revision 2:29e5e670256b, committed 23 months ago
- Comitter:
- brianleong
- Date:
- Thu Dec 01 14:46:00 2022 +0000
- Parent:
- 1:0c173cc105fe
- Commit message:
- Check if photoresistor is covered
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Dec 01 14:38:54 2022 +0000
+++ b/main.cpp Thu Dec 01 14:46:00 2022 +0000
@@ -18,7 +18,7 @@
pc.printf("TempV = %f\r\n",TempV);
T=-1481.96+sqrt(2196200 + ((1.839-float(TempV))/.00000388));
pc.printf("Temp = %3.2f C\r\n",T);
- TempDiff=T-TempStart;
+ TempDiff=T-TempStart; // Temp Compare
if (TempDiff<0.0) {
if (TempDiff<-1) {
firstLED=1;
@@ -29,7 +29,8 @@
secondLED=1;
thirdLED=0;
}
- } if (TempDiff>0.0) {
+ }
+ if (TempDiff>0.0) {
if(TempDiff<1) {
firstLED=1;
secondLED=1;
@@ -48,8 +49,13 @@
pc.printf("PhotoV = %f\r\n",PhotoV);
CellV=3.3*float(Rs)/float(PhotoV)-float(Rs);
pc.printf("Resistance = %.2f kohms\r\n",CellV);
+ if (CellV>10) { // toggle LED 4 if covered
+ fourthLED=1;
+ } else {
+ fourthLED=0;
+ }
}
-void UpdateTemp()
+void UpdateTemp() //button reset inital temp
{
if (debounce.read_ms()>200) { // debouce check for button press
TempV=3.3*Thermistor.read();
@@ -65,13 +71,13 @@
}
int main()
{
- Input.attach(Run,3);
+ Input.attach(Run,1);
debounce.start();
button.rise(&UpdateTemp);
TempV=3.3*Thermistor.read();
TempStart=-1481.96+sqrt(2196200 + ((1.839-float(TempV))/.00000388));
while(1) {
-
+
}
}
\ No newline at end of file
