v1.0.0
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
#include <NewRemoteTransmitter.h>
|
||||
|
||||
// Variabelen
|
||||
int kakuUnit = 14;
|
||||
|
||||
NewRemoteTransmitter transmitter(10911174, 11, 260, 1);
|
||||
|
||||
int sensorValue;
|
||||
int pot1Value; // Switch
|
||||
int pot2Value; // Threshold
|
||||
int pot3Value; // Dim Level
|
||||
|
||||
int switchValueHigh;
|
||||
int switchValueLow;
|
||||
|
||||
int dimLevel = 0;
|
||||
int currentDimLevel = -1;
|
||||
int currentState = -1;
|
||||
|
||||
// LED pin
|
||||
const int ledPin = 13;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
pinMode(ledPin, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
sensorValue = analogRead(A0);
|
||||
pot1Value = analogRead(A1);
|
||||
pot2Value = analogRead(A2);
|
||||
pot3Value = analogRead(A3);
|
||||
|
||||
switchValueHigh = pot1Value+(pot2Value/2);
|
||||
if (switchValueHigh > 1023) {
|
||||
switchValueHigh = 1023;
|
||||
}
|
||||
switchValueLow = pot1Value-(pot2Value/2);
|
||||
if (switchValueLow < 0) {
|
||||
switchValueLow = 0;
|
||||
}
|
||||
|
||||
dimLevel = map(pot3Value, 0, 1023, 0, 15);
|
||||
|
||||
Serial.print("Sensor: ");
|
||||
Serial.println(sensorValue);
|
||||
Serial.print("Pot 1: ");
|
||||
Serial.println(pot1Value);
|
||||
Serial.print("Pot 2: ");
|
||||
Serial.println(pot2Value);
|
||||
Serial.print("Pot 3: ");
|
||||
Serial.println(pot3Value);
|
||||
Serial.print("Dim Level: ");
|
||||
Serial.println(dimLevel);
|
||||
Serial.println("");
|
||||
|
||||
if(sensorValue <= switchValueHigh && currentDimLevel != dimLevel){
|
||||
digitalWrite(ledPin, HIGH);
|
||||
//transmitter.sendUnit(10, true);
|
||||
transmitter.sendDim(kakuUnit, dimLevel);
|
||||
currentDimLevel = dimLevel;
|
||||
currentState = 1;
|
||||
Serial.println("Schakel: aan");
|
||||
Serial.println("");
|
||||
}
|
||||
else if(sensorValue >= switchValueLow && currentState == 1) {
|
||||
digitalWrite(ledPin, LOW);
|
||||
transmitter.sendUnit(10, false);
|
||||
currentDimLevel = -1;
|
||||
currentState = 0;
|
||||
Serial.println("Schakel: uit");
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
//delay(long(1000)*long(60));
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user