-
Notifications
You must be signed in to change notification settings - Fork 0
/
readandsend.ino
44 lines (33 loc) · 876 Bytes
/
readandsend.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
int ldrPin = A0;
int ldrValue = 0;
int tempPin = A1;
int tempValue = 0;
float tempC = 0.0;
unsigned long currentdelay;
unsigned long previousdelay;
int led = LED_BUILTIN; // the pin that the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
//analogReference(INTERNAL1V1);
Serial.begin(9600);
}
void loop()
{
currentdelay = millis();
unsigned int minute = 1000;
if (currentdelay - previousdelay >= minute)
{
// save the last time you blinked the LED
previousdelay = currentdelay;
ldrValue = analogRead(ldrPin);
tempValue = analogRead(tempPin);
tempC = (tempValue*500.0)/1024;
Serial.print(ldrValue);
Serial.print(",");
Serial.println(tempC);
}
analogWrite(led, ldrValue/4);
}