How to connect a 60rpm motor to cayenne


#21

What happened? Do you have any success?


#23

Sir…Yes i got the output…And thanks for all the help…Sir but i have one more question can i ask??


#24

You can ask whatever you want :slight_smile:


#25

The question is i am using an proximity sensor to detect object on convey belt…So i put an trigger that when sensor on motor off…But i am not able create an trigger to off the sensor and on the Motor automatically using cayenne dashboard


#26

I understand what you want to do. Why you cannot create the trigger? You encourage some error or what? :slight_smile:


#27

No sir…But as the sensor is an 2 state thing i mean 1 or 0…But in trigger option i am not able it give an trigger to sensor to stop and make motor on again…Sir how to control this ?


#28

Can you post me a picture?


#29

which one hardware or cayenne dashboard- triggers ?


#30

Please provide as much information as you can, to investigate the problem and solve it!


#31


#32

Aaa I uderstand, when the sensor already detect the object and stop the motor, you want after observe the object to run again the motor.

Try to add delay(ms) //milisecond for example 1000 for 1 second,
and then send to the pin that the motor is connected - analogWrite(motorPin,HIGH);


#33

sir how to add that in this code :
#include <CayenneSerial.h>
#define VIRTUAL_PIN V2
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = “59lfda5thl”;
int motorPin = 9;
void setup()
{
//Baud rate can be specified by calling Cayenne.begin(token, 9600);
Cayenne.begin(token);
}
//Enable or disable the motor based on value received on virtual pin.
CAYENNE_IN (V2)
{
int speed = 255;
// read the integer value which should be 0 or 1
int enabled = getValue.asInt();
if (enabled == 1) {
// turns on the motor at the specified speed
analogWrite(motorPin,speed);
} else {
// turn motor off
analogWrite(motorPin,0);
}
}

void loop()
{
Cayenne.run();
}


#34

i tried writing this code and it was working but how get this code into cayenne?
code:
float metalDetected;
int monitoring;
int metalDetection = 2;
int motorPin = 3;
int motorPin_1 = 4;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(motorPin, OUTPUT);
pinMode(motorPin_1, OUTPUT);
pinMode(metalDetection, INPUT);
}

void loop() {

// put your main code here, to run repeatedly:
digitalWrite(motorPin , HIGH);
digitalWrite(motorPin_1 , LOW);
monitoring = digitalRead(metalDetection);
if (monitoring == HIGH)
{
//Serial.println(“Metal is Detected”);
digitalWrite(motorPin , LOW);
digitalWrite(motorPin_1 , LOW);
delay(5000);
digitalWrite(motorPin_1 , LOW);
digitalWrite(motorPin , HIGH);
delay(5000);
}

}


#35

What do you want to see in the Cayenne. When the motor is ON/OFF ?


#36

Sir my main purpose is that…The motor must stop at sensor for 10 sec…And again run even if the sensor input is high


#37

Yes sir, I understand this. But in Cayenne dashboard what do you want to monitor? The state of the motor? I am asking because the logic that you send seems OK. We can just add Virtual Pin monitor and connect it with widget to the dashboard?


#38

sir,
as u see i want to make a stop and run using proximty sensor. but as u see in the below picture i am not able trigger in such a way that after certain interval the motor must start even if the sensor is high


so to achieve that wat should i do??


#39

You use the triggering,

drag your arduino sensor, set trigger condition (if), in this case, when it (sensor) is HIGH, then drag your motor widget of that same arduino, then set LOW or OFF.

as for your code, i cant really understand. Let me ask if this is what you wanted…

You want to turn your motor ON from Cayenne?
The motor stops when the Proximity sensor is HIGH?
So you have to remove the object in front of the sensor so the motor can start again? OR
You want to use cayenne to control turn the motor ON again, doesnt matter if the object is triggering the sensor HIGH?


#40

Yes sir…Even if the sensor is high i want the motor to run again after a time delay…How to achieve this ?