@Suresh-Mali
@mfalkvidd
Thank you for your help ,I'll be trying it tonight and I let you know
Thanks
oscarc
@oscarc
Best posts made by oscarc
-
RE: I am not able to stop the blinds motor once the first command is sent.
-
RE: What is the difference between arduino nano (FT232 chip) and arduino nano CH340 chip ?
I am using an arduino uno as gateway and my sensors are the chip arduino minipro with the ch340 , but you do need the ch340 programer and drivers $6 dollars at amazon
Latest posts made by oscarc
-
RE: Multisensor Multiactuator Sketch / Testboard - tested with FHEM Controller
@marekd Thank you, it does help :
-
RE: Multisensor Multiactuator Sketch / Testboard - tested with FHEM Controller
Question :
For the dallas sensor , if I add more sensors can I add them to the same pin (D6) or it needs a different pin ? -
RE: What is the difference between arduino nano (FT232 chip) and arduino nano CH340 chip ?
I am using an arduino uno as gateway and my sensors are the chip arduino minipro with the ch340 , but you do need the ch340 programer and drivers $6 dollars at amazon
-
RE: Motor Control with S_cover
@TheoL
not really ,I think I'm going to use relays instead of the motor controller
Thanks. -
RE: I am not able to stop the blinds motor once the first command is sent.
@Suresh-Mali
@mfalkvidd
Thank you for your help ,I'll be trying it tonight and I let you know
Thanks -
Motor Control with S_cover
Could some one please show me an example of how to use the s_cover commands?
My project is an window blind with a dc motor an arduino mini pro 2 reed switches and an external motor driver ,I have little to no experience with programming to be honest ,I already tested another user sketch but the motor just does't stop once it hits the reed switch and I already tried debouncing the switch , Help is really appreciate it
Thank you#include <SPI.h> #include <MySensor.h> int motor_forward = 5; int motor_reverse = 6; int stopSwLeft = 3; int stopSwRight = 4; //int stopSwNow = 7; int CHILD_CURTAIN_ID =1; int lastState; MySensor gw; MyMessage msg_S_COVER_U(CHILD_CURTAIN_ID, V_UP); MyMessage msg_S_COVER_D(CHILD_CURTAIN_ID, V_DOWN); MyMessage msg_S_COVER_S(CHILD_CURTAIN_ID, V_STOP); //MyMessage msg(CHILD_CURTAIN_ID,V_UP); // the setup routine runs once when you press reset: void setup() { Serial.begin(115200); // initialize the digital pin as an output for L239D. pinMode(motor_forward, OUTPUT); pinMode(motor_reverse, OUTPUT); // initialize the digital pin as an output for Stop Switches. pinMode(stopSwLeft, INPUT_PULLUP); pinMode(stopSwRight, INPUT_PULLUP); //pinMode(stopSwNow, INPUT_PULLUP); gw.begin(incomingMessage, AUTO, true); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Window_Curtain", "1.0"); gw.present(CHILD_CURTAIN_ID, S_COVER); } void loop(){ gw.process(); } void cover(int coverVal){ //int coverVal = gw.loadState(CHILD_CURTAIN_ID); Serial.print("Cover is : "); lastState = coverVal; switch (coverVal) { case 0: Serial.println("Opening"); while (lastState == coverVal) { m_left(); gw.process(); checkHWInnputs(); coverVal = gw.loadState(CHILD_CURTAIN_ID); } gw.send(msg_S_COVER_U.set(V_UP)); break; case 1: Serial.println("Closing"); while (lastState == coverVal) { m_right(); gw.process(); checkHWInnputs(); coverVal = gw.loadState(CHILD_CURTAIN_ID); } gw.send(msg_S_COVER_D.set(V_DOWN)); break; case 2: Serial.println("Idle"); while (lastState == coverVal) { m_stop(); gw.process(); checkHWInnputs(); coverVal = gw.loadState(CHILD_CURTAIN_ID); } gw.send(msg_S_COVER_S.set(V_STOP)); break; } return; } void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. Serial.println("recieved incomming message"); switch (message.type) { case V_UP: gw.saveState(CHILD_CURTAIN_ID, 0); Serial.print("Incoming change for ID_S_COVER:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println("V_UP"); cover(gw.loadState(CHILD_CURTAIN_ID)); Serial.print("Done cover procedure"); //m_right(); break; case V_DOWN: gw.saveState(CHILD_CURTAIN_ID, 1); Serial.print("Incoming change for ID_S_COVER:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println("V_DOWN"); cover(gw.loadState(CHILD_CURTAIN_ID)); Serial.print("Done cover procedure"); //m_left(); break; case V_STOP: gw.saveState(CHILD_CURTAIN_ID, 2); Serial.print("Incoming change for ID_S_COVER:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println("V_STOP"); cover(gw.loadState(CHILD_CURTAIN_ID)); Serial.print("Done cover procedure"); m_stop(); break; } Serial.print("exiting incoming message"); return; } // the loop routine runs over and over again forever: void m_right() { digitalWrite(motor_forward, HIGH); //terminal D1 will be HIGH digitalWrite(motor_reverse, LOW); //terminal D2 will be LOW exit; } void m_left() { digitalWrite(motor_forward, LOW); //terminal D1 will be LOW digitalWrite(motor_reverse, HIGH); //terminal D2 will be HIGH exit; } void m_stop() { digitalWrite(motor_forward,HIGH ); //terminal D1 will be LOW digitalWrite(motor_reverse, HIGH); //terminal D2 will be HIGH exit; } void checkHWInnputs() { if (digitalRead(stopSwLeft) == LOW) { cover(1); m_stop() ; } if (digitalRead(stopSwRight) == LOW) { cover(0); m_stop() ; } }
-
RE: I am not able to stop the blinds motor once the first command is sent.
@Suresh-Mali
I already tried but it just jumps from forward to backward without stooping ,without the stops it works fine ,I push up and it moves ,I push the stop and stops but I really want to use the stops to prevent damage, I'm using an arduino mini pro with an external motor driver.#include <SPI.h> #include <MySensor.h> #include <Bounce2.h> int motor_forward = 5; int motor_reverse = 6; #define stopSwLeft 2 #define stopSwRight 3 int CHILD_CURTAIN_ID =1; int lastState; MySensor gw; MyMessage msg_S_COVER_U(CHILD_CURTAIN_ID, V_UP); MyMessage msg_S_COVER_D(CHILD_CURTAIN_ID, V_DOWN); MyMessage msg_S_COVER_S(CHILD_CURTAIN_ID, V_STOP); Bounce debouncer = Bounce(); Bounce debouncer1 = Bounce(); void setup() { Serial.begin(115200); // initialize the digital pin as an output for L239D. pinMode(motor_forward, OUTPUT); pinMode(motor_reverse, OUTPUT); // initialize the digital pin as an output for Stop Switches. pinMode(stopSwLeft, INPUT); pinMode(stopSwRight, INPUT); digitalWrite(stopSwLeft,HIGH); digitalWrite(stopSwRight,HIGH); debouncer.attach(stopSwLeft); debouncer.interval(50); debouncer1.attach(stopSwRight); debouncer1.interval(50); gw.begin(incomingMessage, AUTO, true); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Window_Curtain", "1.0"); gw.present(CHILD_CURTAIN_ID, S_COVER); } void loop(){ gw.process(); } void cover(int coverVal){ //int coverVal = gw.loadState(CHILD_CURTAIN_ID); Serial.print("Cover is : "); lastState = coverVal; switch (coverVal) { case 0: Serial.println("Opening"); while (lastState == coverVal) { m_left(); gw.process(); checkHWInnputs(); coverVal = gw.loadState(CHILD_CURTAIN_ID); } gw.send(msg_S_COVER_U.set(V_UP)); break; case 1: Serial.println("Closing"); while (lastState == coverVal) { m_right(); gw.process(); checkHWInnputs(); coverVal = gw.loadState(CHILD_CURTAIN_ID); } gw.send(msg_S_COVER_D.set(V_DOWN)); break; case 2: Serial.println("Idle"); while (lastState == coverVal) { m_stop(); gw.process(); //checkHWInnputs(); coverVal = gw.loadState(CHILD_CURTAIN_ID); } gw.send(msg_S_COVER_S.set(V_STOP)); break; } return; } void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. Serial.println("recieved incomming message"); switch (message.type) { case V_UP: gw.saveState(CHILD_CURTAIN_ID, 0); Serial.print("Incoming change for ID_S_COVER:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println("V_UP"); cover(gw.loadState(CHILD_CURTAIN_ID)); Serial.print("Done cover procedure"); break; case V_DOWN: gw.saveState(CHILD_CURTAIN_ID, 1); Serial.print("Incoming change for ID_S_COVER:"); Serial.print("message.sensor"); Serial.print(", New status: "); Serial.println("V_DOWN"); cover(gw.loadState(CHILD_CURTAIN_ID)); Serial.print("Done cover procedure"); break; case V_STOP: gw.saveState(CHILD_CURTAIN_ID, 2); Serial.print("Incoming change for ID_S_COVER:"); Serial.print("message.sensor"); Serial.print(", New status: "); Serial.println("V_STOP"); cover(gw.loadState(CHILD_CURTAIN_ID)); Serial.print("Done cover procedure"); break; } Serial.print("exiting incoming message"); return; } //the loop routine runs over and over again forever: void m_right() { digitalWrite(motor_forward, HIGH); //terminal D1 will be HIGH digitalWrite(motor_reverse, LOW); //terminal D2 will be LOW } void m_left() { digitalWrite(motor_forward, LOW); //terminal D1 will be LOW digitalWrite(motor_reverse, HIGH); //terminal D2 will be HIGH } void m_stop() { digitalWrite(motor_forward, LOW); //terminal D1 will be LOW digitalWrite(motor_reverse, LOW ); //terminal D2 will be HIGH } void checkHWInnputs() { debouncer.update(); debouncer1.update(); int value = debouncer.read(); int value1 = debouncer1.read(); if (value == LOW) { Serial.println("Detected stop button push. Stopping"); cover(1); } { if (value1 == LOW) Serial.println("Detected stop button push. Stopping"); cover(0); } }
-
RE: I am not able to stop the blinds motor once the first command is sent.
@Suresh-Mali
I tried your sketch but i'm having problems with reed switch bouncing (stop sensors) ,do you have any suggestions how to avoid this ? I'm using an arduino mini pro ,with magnetic reed switches .