Arduino: 1.6.5 (Windows 7), Platine: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
L_fter_Steuerung_PWM:120: error: expected declaration before '}' token
expected declaration before '}' token
#include "DHT.h"
#include <SPI.h>
#include <Wire.h>
#include <LiquidCrystal.h> // Using version 1.2.1
#include <SC16IS750.h>
#include <string.h>
#include <NDIRZ16.h>
#define DHT1PIN A0 // what pin we're connected to
#define DHT2PIN A1
#define DHT1TYPE DHT11 // DHT 11
#define pwm 9
#define RELAY_ON 0
#define RELAY_OFF 1
#define Relay_3 8 // Relais werden den Pins zugeordnet Ventilator
#define Relay_1 10 // Ventilator
#define Relay_2 13 // Ventilator
#define Relay_4 22 // CO2 Ventil
#define Relay_5 23 // Luftbefeuchter
SC16IS750 i2cuart = SC16IS750(SC16IS750_PROTOCOL_I2C,SC16IS750_ADDRESS_BB); // CO2 Sensor
NDIRZ16 mySensor = NDIRZ16(&i2cuart);
DHT dht1(DHT1PIN, DHT1TYPE);
DHT dht2(DHT2PIN, DHT1TYPE);
const int buttonPin = 6; // the number of the pushbutton pin
const int ledPin = 7; // the number of the LED pin
int ledState = LOW; // the current state of the output pin
int buttonState = LOW; // the current reading from the input pin
int lastButtonState = HIGH; // the previous reading from the input pin
int reading;
long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 50; // the debounce time; increase if the output flickers
LiquidCrystal theDisplay(12, 11, 5, 4, 3, 2);
void setup() {
Serial.begin(115200);
i2cuart.begin(9600);
if (i2cuart.ping()) {
Serial.println("SC16IS750 found.");
Serial.println("Wait 10 seconds for sensor initialization...");
} else {
Serial.println("SC16IS750 not found.");
while(1);
}
power(1);
delay(10000);
};
void loop(){
theDisplay.setCursor(0, 1);
Serial.println("-------");
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
dht1.begin();
dht2.begin();
Serial.println(" Fan Speed ");
Serial.println(" Controlling ");
delay(1000);
analogWrite(pwm, 255);
Serial.println("Circuit Digest ");
delay(1000);
digitalWrite(Relay_1, RELAY_OFF); // Relay 1 Ventilator
digitalWrite(Relay_2, RELAY_OFF); // Relay 2 Ventilator
digitalWrite(Relay_3, RELAY_OFF); // Relay 3 Ventilator
digitalWrite(Relay_4, RELAY_OFF); // Relay 4 CO2 Ventil
digitalWrite(Relay_5, RELAY_OFF); // Relay 5 Luftbefeuchter
pinMode(Relay_1, OUTPUT); // Relay 1 Ventilator
pinMode(Relay_2, OUTPUT); // Relay 2 Ventilator
pinMode(Relay_3, OUTPUT); // Relay 3 Ventilator
pinMode(Relay_4, OUTPUT); // Relay 3 CO2 Ventil
pinMode(Relay_5, OUTPUT); // Relay 3 Luftbefeuchter
}
void power (uint8_t state) {
i2cuart.pinMode(0, INPUT); //set up for the power control pin
if (state) {
i2cuart.pinMode(0, INPUT); //turn on the power of MH-Z16
} else {
i2cuart.pinMode(0, OUTPUT);
i2cuart.digitalWrite(0, 0); //turn off the power of MH-Z16
}
}
calling this function.
void calibrate() {
i2cuart.pinMode(1, OUTPUT); //set up for the calibration pin.
i2cuart.digitalWrite(1, LOW); //start calibration of MH-Z16 under 400ppm
delay(10000); //5+ seconds needed for the calibration process
i2cuart.digitalWrite(1, HIGH); //toggle the pin HIGH back to normal operation
}
}
int sensorValue = analogRead(A2);
int level = sensorValue * (11/ 1023.0);
Serial.print ("level: ");
Serial.println(level);
Serial.println(sensorValue);
reading = digitalRead(buttonPin);
if (reading != lastButtonState) {
lastDebounceTime = millis();
lastButtonState = reading;
}
if ((millis() - lastDebounceTime) > debounceDelay) {
if (buttonState != lastButtonState) {
buttonState = lastButtonState;
if (buttonState == HIGH) {
ledState = !ledState;
digitalWrite(ledPin, ledState);
Serial.print("ledState ");
Serial.println(ledState);
}
}
}