Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *Divya Inaganti
- *June, 16, 2017
- *Temperature and Humidity Sensor
- */
- //www.elegoo.com
- //2016.06.13
- #include <SimpleDHT.h>
- // for DHT11,
- // VCC: 5V or 3V
- // GND: GND
- // DATA: 2
- int pinDHT11 = 2;
- SimpleDHT11 dht11;
- const int photoPin = A0;
- const int PinRed= 9;
- const int PinGreen=10;
- const int PinBlue= 11;
- int photoValue= 0;
- int lightVal= 0;
- const int pinButton = 4;
- int newButton = 0;
- int lastButton = 0;
- unsigned long timeVal;
- int minimum= 1000;
- int maximum= -1000;
- void setup() {
- Serial.begin (9600);
- pinMode(photoPin, INPUT);
- pinMode (PinRed, OUTPUT);
- pinMode (PinGreen, OUTPUT);
- pinMode (PinBlue, OUTPUT);
- pinMode(pinButton, INPUT);
- analogWrite(PinRed, 255);
- analogWrite(PinGreen, 0);
- analogWrite(PinBlue,0);
- delay(200);
- analogWrite(PinRed, 0);
- analogWrite(PinGreen, 255);
- analogWrite(PinBlue,0);
- delay(200);
- analogWrite(PinRed, 0);
- analogWrite(PinGreen, 0);
- analogWrite(PinBlue,255);
- delay(200);
- analogWrite(PinRed, 0);
- analogWrite(PinGreen, 0);
- analogWrite(PinBlue,0);
- }
- void calibrate()
- {
- maximum = -5000;
- minimum = 5000;
- analogWrite(PinGreen, 0);
- analogWrite(PinRed, 0);
- analogWrite(PinBlue, 0);
- delay(200);
- analogWrite(PinRed, 255);
- delay(200);
- analogWrite(PinRed, 0);
- timeVal = millis();
- while(millis()- timeVal < 5000)
- {
- photoValue = analogRead(photoPin);
- if(photoValue > maximum)
- {
- maximum = photoValue;
- }
- else if(photoValue < minimum)
- {
- minimum = photoValue;
- }
- }
- Serial.println(minimum);
- Serial.println(maximum);
- analogWrite(PinGreen, LOW);
- delay(200);
- analogWrite(PinRed, LOW);
- }
- boolean debounce(boolean last)
- {
- boolean current = digitalRead(pinButton);
- if (last != current)
- {
- delay(5);
- current = digitalRead(pinButton);
- }
- }
- void loop() {
- // start working...
- Serial.print
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement