RBE1001Lib
Photoresistor.ino
Go to the documentation of this file.
1 /*
2  * A basic analog read example. This uses Arduino's pre-packaged analogRead() function, which
3  * doesn't use the ESP32's calibration system, but is good enough for our purposes here.
4  */
5 
6 #include <Arduino.h>
7 #include <RBE1001Lib.h>
8 
9 const int photoresistorPin = 34;
10 const uint32_t LINE_SENSOR_INTERVAL = 10;
11 
12 /*
13  * This is the standard setup function that is called when the ESP32 is rebooted
14  * It is used to initialize anything that needs to be done once.
15  */
16 void setup()
17 {
18  // This will initialize the Serial as 115200 for prints
19  Serial.begin(115200);
20 
21  //Pins typically default to INPUT, but the code reaads easier if you are explicit:
22  pinMode(photoresistorPin, INPUT);
23 }
24 
25 
26 /*
27  * The main loop for the program. The loop function is repeatedly called
28  * once the ESP32 is started.
29  */
30 void loop()
31 {
32  //delay(100);
33  static uint32_t lastTime = 0;
34  if(millis() - lastTime > LINE_SENSOR_INTERVAL)
35  {
36  int adcPhotoresistor = analogRead(photoresistorPin);
37  Serial.print(millis());
38  Serial.print('\t');
39  Serial.println(adcPhotoresistor);
40 
41  lastTime += LINE_SENSOR_INTERVAL;
42  }
43 
44 }
const uint32_t LINE_SENSOR_INTERVAL
const int photoresistorPin
void setup()
void loop()