added photodiode code
This commit is contained in:
3
.vscode/arduino.json
vendored
3
.vscode/arduino.json
vendored
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"sketch": "blinds-controller.ino",
|
||||
"output": "build",
|
||||
"board": "arduino:samd:mkr1000"
|
||||
"board": "arduino:samd:mkr1000",
|
||||
"port": "/dev/tty.usbmodem2112401"
|
||||
}
|
||||
1
.vscode/c_cpp_properties.json
vendored
1
.vscode/c_cpp_properties.json
vendored
@@ -7,6 +7,7 @@
|
||||
"compilerArgs": [
|
||||
"-mcpu=cortex-m0plus",
|
||||
"-mthumb",
|
||||
"-w",
|
||||
"-std=gnu++11",
|
||||
"-ffunction-sections",
|
||||
"-fdata-sections",
|
||||
|
||||
@@ -9,6 +9,7 @@ int pdValue = 0;
|
||||
void setup()
|
||||
{
|
||||
blind.attach(9);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void openBlind()
|
||||
@@ -17,6 +18,9 @@ void openBlind()
|
||||
blind.write(position);
|
||||
delay(15);
|
||||
}
|
||||
Serial.print("Open Blind End Position: ");
|
||||
Serial.print(position);
|
||||
Serial.print("\n");
|
||||
}
|
||||
|
||||
void closeBlind(){
|
||||
@@ -24,10 +28,21 @@ void closeBlind(){
|
||||
blind.write(position);
|
||||
delay(15);
|
||||
}
|
||||
Serial.print("Close Blind End Position: ");
|
||||
Serial.print(position);
|
||||
Serial.print("\n");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
pdValue = analogRead(photoDiode);
|
||||
Serial.println(String(pdValue/1024.0 * 100)+"%");
|
||||
delay(500);
|
||||
//if pdValue below 50% and inSchedule then open blind else close blind
|
||||
if(pdValue/1024.0 < 0.5){
|
||||
openBlind();
|
||||
}else{
|
||||
closeBlind();
|
||||
}
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,7 @@ int pdValue = 0;
|
||||
void setup()
|
||||
{
|
||||
blind.attach(9);
|
||||
SerialUSB.begin(9600);
|
||||
}
|
||||
|
||||
void openBlind()
|
||||
@@ -18,6 +19,9 @@ void openBlind()
|
||||
blind.write(position);
|
||||
delay(15);
|
||||
}
|
||||
SerialUSB.print("Open Blind End Position: ");
|
||||
SerialUSB.print(position);
|
||||
SerialUSB.print("\n");
|
||||
}
|
||||
|
||||
void closeBlind(){
|
||||
@@ -25,10 +29,21 @@ void closeBlind(){
|
||||
blind.write(position);
|
||||
delay(15);
|
||||
}
|
||||
SerialUSB.print("Close Blind End Position: ");
|
||||
SerialUSB.print(position);
|
||||
SerialUSB.print("\n");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
pdValue = analogRead(photoDiode);
|
||||
|
||||
SerialUSB.println(String(pdValue/1024.0 * 100)+"%");
|
||||
delay(500);
|
||||
//if pdValue below 50% and inSchedule then open blind else close blind
|
||||
if(pdValue/1024.0 < 0.5){
|
||||
openBlind();
|
||||
}else{
|
||||
closeBlind();
|
||||
}
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
@@ -10,16 +10,17 @@ int pdValue = 0;
|
||||
|
||||
#line 9 "/Users/nico/Documents/GitHub/blinds-controller/blinds-controller.ino"
|
||||
void setup();
|
||||
#line 14 "/Users/nico/Documents/GitHub/blinds-controller/blinds-controller.ino"
|
||||
#line 15 "/Users/nico/Documents/GitHub/blinds-controller/blinds-controller.ino"
|
||||
void openBlind();
|
||||
#line 22 "/Users/nico/Documents/GitHub/blinds-controller/blinds-controller.ino"
|
||||
#line 26 "/Users/nico/Documents/GitHub/blinds-controller/blinds-controller.ino"
|
||||
void closeBlind();
|
||||
#line 29 "/Users/nico/Documents/GitHub/blinds-controller/blinds-controller.ino"
|
||||
#line 36 "/Users/nico/Documents/GitHub/blinds-controller/blinds-controller.ino"
|
||||
void loop();
|
||||
#line 9 "/Users/nico/Documents/GitHub/blinds-controller/blinds-controller.ino"
|
||||
void setup()
|
||||
{
|
||||
blind.attach(9);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void openBlind()
|
||||
@@ -28,6 +29,9 @@ void openBlind()
|
||||
blind.write(position);
|
||||
delay(15);
|
||||
}
|
||||
Serial.print("Open Blind End Position: ");
|
||||
Serial.print(position);
|
||||
Serial.print("\n");
|
||||
}
|
||||
|
||||
void closeBlind(){
|
||||
@@ -35,11 +39,22 @@ void closeBlind(){
|
||||
blind.write(position);
|
||||
delay(15);
|
||||
}
|
||||
Serial.print("Close Blind End Position: ");
|
||||
Serial.print(position);
|
||||
Serial.print("\n");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
pdValue = analogRead(photoDiode);
|
||||
|
||||
Serial.println(String(pdValue/1024.0 * 100)+"%");
|
||||
delay(500);
|
||||
//if pdValue below 50% and inSchedule then open blind else close blind
|
||||
if(pdValue/1024.0 < 0.5){
|
||||
openBlind();
|
||||
}else{
|
||||
closeBlind();
|
||||
}
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user