Thanks, yes, this was the reason i was given...May I ask why no microcontroller is allowed?
there would not be sufficient quantities required to warrant a microcontroller.
// generated by mBlock5 for <your product>
// codes make you happy
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
float CurrentState = 0;
float OldPinState = 0;
float relayApin = 0;
float relayBpin = 0;
float wchRelay = 0;
float inputPin = 0;
float wchedge = 0;
float dbnccntr = 0;
float pinstate = 0;
void debounce (){
dbnccntr = 0;
if((CurrentState == 1.000000) && (OldPinState == 0.000000)){
pinstate = 1;
dbnctask_N(pinstate);
CurrentState = 1;
}
if((CurrentState == 0.000000) && (OldPinState == 1.000000)){
pinstate = 0;
dbnctask_N(pinstate);
CurrentState = 0;
}
}
void dbnctask_N (double pinstate){
while(!(dbnccntr > 5))
{
_loop();
_delay(0.02);
dbnccntr += 1;
if(!((digitalRead(inputPin) == pinstate))){
dbnccntr = 0;
}
}
}
void PulseRelay_N (double wchRelay){
_delay(5);
digitalWrite(wchRelay,1);
_delay(3);
digitalWrite(wchRelay,0);
}
void _delay(float seconds) {
long endTime = millis() + seconds * 1000;
while(millis() < endTime) _loop();
}
void setup() {
pinMode(relayApin,OUTPUT);
pinMode(relayBpin,OUTPUT);
pinMode(inputPin,INPUT);
pinMode(wchRelay,OUTPUT);
relayApin = 9;
relayBpin = 10;
inputPin = 5;
digitalWrite(relayApin,0);
digitalWrite(relayBpin,0);
CurrentState = digitalRead(inputPin);
OldPinState = CurrentState;
while(1) {
CurrentState = digitalRead(inputPin);
if(!((CurrentState == OldPinState))){
debounce();
if(CurrentState == 1.000000){
PulseRelay_N(relayApin);
}else{
PulseRelay_N(relayBpin);
}
OldPinState = CurrentState;
}
_loop();
}
}
void _loop() {
}
void loop() {
_loop();
}
???there would not be sufficient quantities required to warrant a microcontroller.
Actually might fit in a smaller ATTINY part -mBlock is really implementing binary variables as float? Surprizing.
It's no problem if you have a controller with 8k flash like ATtiny85, a cost optimal solution would however target to really tiny 50 cent processor.
???
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?