ASL shield
✔ Up to 24 stairs setup availability.
✔ Fade out effect. PWM modulation.
✔ Can be connected wirelessly with more than 20 of the leading home automation controllers on the market.
✔ Ready to use sketch .
✔ Combined with Mysensors lib.
(can be included as relay, in this case no light sensor needed, just create a Day/Night scene inside your home controller)
HOW TO BUILD:
1. Follow the schematic sketch bellow to wire it up.
2. Download and install Mysensor-master(optional) and ShiftPWM -master libraries to Arduino IDE:
3. Download a sketch .
( Two options: choose sketch 'ForASLMysensorInkluded' or 'ForASLOnlyLightSensor' for controlling
day/night mode.
4. Edit code : Set number of stairs, pause between on/off, check your sensors type, adjust photocell
sensitivity (if using)
5. Upload the code to Arduino Nano.
6. Insert Arduino to ASL Shield.
7. Insert NRF24L01+ modul . ( optional )
8. Set Mysensors plugin to including mode. ( optional )
8. Power up ASL Shield.
( optional - means you can skip this step ,if ‘ForASLOnlyLightSensor.ino’ sketch is used )
For more infore visit:
https://Firefly-Glow.com
License: Attribution-ShareAlike (CC-BY-SA)
/*
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters.
* repeater and gateway builds a routing tables in EEPROM which keeps track of
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributo
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*ShiftRegister74HC595.h - Library for easy control of the 74HC595 shift
* Created by Timo Denk (www.simsso.de), Nov 2014.
* Additional information are available on http://shiftregister.simsso.de/
* Released into the public domain.
*
*/
#define MY_RADIO_NRF24 //For moor info visit www //.mysensors.org
#define MY_REPEATER_FEATURE //
#include <SPI.h> //
#include <MySensors.h> //
#include <ShiftRegister74HC595.h>
ShiftRegister74HC595 sr (3, 6, 7, 8); // ShiftRegister set-up //Do not change
#define sensorBottom_PIN A1 // Bottom sensor // Do not change
#define sensorUpper_PIN A2 // Upper sensor //Do not change
#define lightSensor_PIN A5 // Light sensor //Do not change
boolean climblightSequence = false;
boolean declimblightSequence = false;
boolean MysenSor=1;
int numberOfstairs = 19; //Set number of stairs //!!!!!!
int pause = 10000; //Set pause between on/off //!!!!!!!
int val;
int sensor;
void before() {
MysenSor = loadState(sensor); // Seting relay to last known //state (using eeprom //storage)
}
void presentation() {
present(sensor, S_LIGHT); // For moor info visit www.mysensors.org
}
void receive(const MyMessage &message) { // For moor info visit www.mysensors.org
if (message.type == V_LIGHT) {
MysenSor = message.getBool();
saveState(message.sensor, message.getBool());
}
}
void setup() {
}
void loop() {
val = analogRead(5); //Checking light level || Mysensors relay ON/OFF stage
if (val <= 10 || MysenSor==1 ) { // Adjust photocell cencivity // . (val<10 dark.....val>800
// Delete "val <= 10 ||" if //using Mysensors relay for //controling a Day/Night //mode..!!!
// Delete "|| MysenSor==1" if //using photocell..!!!
BottomTriggerFire(); //Checking bottom sensor
UpperTrigerFire(); //Checking upper sensor
climbLightSequence(); //Stairs on/off from down to //up
declimbLightSequence(); //Stairs on/off from up to //down
}
}
void BottomTriggerFire() {
if (analogRead (sensorBottom_PIN) >= 550 ) { //Depands of the sensor tipe //, if trigger signal is //0 ,than change the //comparation to opposide //value.
climblightSequence = true;
}
}
void UpperTrigerFire() {
if (analogRead(sensorUpper_PIN) >= 550) {
declimblightSequence = true;
}
}
void climbLightSequence() {
if (climblightSequence == true && declimblightSequence == false) {
for (int i = 0; i < numberOfstairs; i++) {
sr.set(i, HIGH);
delay(250);
}
delay(pause); // paus before to switch off
for (int i = 0; i < numberOfstairs; i++) {
sr.set(i, LOW);
delay(250);
}
climblightSequence = false;
}
}
void declimbLightSequence() {
if (declimblightSequence == true && climblightSequence == false) {
for (int i = numberOfstairs; i >= 0; i--) {
sr.set(i, HIGH);
delay(250);
}
delay(pause); // paus before to switch off
for (int i = numberOfstairs; i >= 0; i--) {
sr.set(i, LOW);
delay(250);
}
declimblightSequence = false;
}
}
#define SHIFTPWM_NOSPI // Uncomment this part to NOT use the SPI port and change the pin numbers. This is 2.5x slower Do not change!!!
const int ShiftPWM_dataPin = 6; // Do not change!!!
const int ShiftPWM_clockPin = 7; // Do not change!!!
const int ShiftPWM_latchPin = 8; // Do not change!!!
#include <ShiftPWM.h>
const bool ShiftPWM_invertOutputs = false;
const bool ShiftPWM_balanceLoad = false;
#define sensorLight_PIN A5 // Light sensor Do not change!!!
#define sensorBottom_PIN A1 // Bottom sensor Do not change!!!
#define sensorUpper_PIN A2 // Upper sensor Do not change!!!
unsigned char maxBrightness = 100; // Here you set the number of brightness levels. Adjust(0-255)!!
unsigned char pwmFrequency = 75; // These values affect the load of ShiftPWM
unsigned int numRegisters = 3; // Number of shift registers Do not change!!!
unsigned int numOutputs = numRegisters * 8;
unsigned int numRGBLeds = numRegisters * 8 / 3;
unsigned int fadingMode = 0; // start with all LED's off.
boolean sensorUpperActive;
boolean sensorBottomActive;
int numberOfstairs=24; // Setup Number of Your stairs. Adjust UP TO 24 !!!!
int pause=30000; // Setup delay ON/OFF Adjust!!!
byte faidoutSpeed=5; // How fast to fadeout Adjust!!!
byte faidinSpeed=5; // How fast to fadein Adjust!!!
int val;
void setup() {
ShiftPWM.SetAmountOfRegisters(numRegisters);
ShiftPWM.Start(pwmFrequency, maxBrightness);
pinMode(sensorBottom_PIN, INPUT);
pinMode(sensorUpper_PIN, INPUT);
pinMode(sensorLight_PIN, INPUT);
Serial.begin(9600);
}
void loop() {
val = analogRead(5); //Checking light level
if (val <= 1000) { // Adjust photocell cencivity. (val<10 dark.....val>800 bright..) !!!!!!!!
BottomTriggerFire(); //Checking bottom sensor
UpperTrigerFire(); //Checking upper sensor
switchONOFFfromdown(); //Stairs on/off from down to up
switchONOFFfromUp(); //Stairs on/off from up to down
}
}
void BottomTriggerFire() {
if (analogRead (sensorBottom_PIN) >= 550 ) { //Dependof the sensor type, if 0 when triggered ,than change the comparison to opposite value
sensorBottomActive = true;
}
}
void UpperTrigerFire() {
if (analogRead(sensorUpper_PIN) >= 550) {
sensorUpperActive = true;
}
}
void switchONOFFfromdown() {
if (sensorBottomActive==true && sensorUpperActive==false){
for(int i=0; i<numberOfstairs; i++){
Serial.print(i);
for(int a=0; a<maxBrightness; a++){
ShiftPWM.SetOne(i,a);
delay(faidoutSpeed);
}
}
delay(pause);
for(int i=0; i<numberOfstairs; i++){
//Serial.print(i);
for(int a=maxBrightness;a>=0;a--){
ShiftPWM.SetOne(i,a);
if(a==0){
ShiftPWM.SetOne(i,0);
}
delay(faidinSpeed);
}
}
sensorBottomActive = false ;
}
}
void switchONOFFfromUp () {
if ( sensorUpperActive==true && sensorBottomActive==false) {
for(int i=numberOfstairs-1; i>=0; i--){
Serial.print(i);
for(int a=0; a<maxBrightness; a++){
ShiftPWM.SetOne(i,a);
delay(faidoutSpeed);
}
}
delay(pause);
for(int i=numberOfstairs-1; i>=0; i--){
//Serial.print(i);
for(int a=maxBrightness;a>=0;a--){
ShiftPWM.SetOne(i,a);
if(a==0){
ShiftPWM.SetOne(i,0);
}
delay(faidinSpeed);
}
}
sensorUpperActive= false ;
}
}
Aivaredze
Comments