How to control actuator with C program code, not with trigger

I have a DC motor control project with load cell and scheduling parameters. The DC motor will actively work when the scheduling time has arrived, and the weight of the weighed load has met the set point. I’m having trouble using the trigger feature to control my project, can Cayenne provide a control feature by using/uploading C-based program code? in order to meet my project performance rules.

You can use the button on cayenne UI to send a downlink to turn ON the motor, but the logic to handle the turn OFF based on the weighing scale should be handled on the device end itself.

Thanks for the answer, but my problem is how to combine the motor activation schedule and send the preset value from the cayenne as the loadcell reading limit value so that the DC motor is active.
for example I want to set the motor and weighing to be active at 08.00 Am and the maximum weighing weight is 10 Kg, then the system will automatically work (the motor will be active if the time has met and the weighing limit of 10 Kg has been reached, the DC motor is active.
how do i do control, input loadcell and schedule parameters through the current cayenne platform features?
Please help, thank you

Based on this example code Cayenne-MQTT-Arduino/GenericDigitalOutput.ino at master · myDevicesIoT/Cayenne-MQTT-Arduino · GitHub

You will need to add an actuator to the cayenne dashboard to turn ON/OFF button and read it on the device using:-

CAYENNE_IN(VIRTUAL_CHANNEL)
{
	int value = getValue.asInt();
	CAYENNE_LOG("Channel %d, pin %d, value %d", VIRTUAL_CHANNEL, ACTUATOR_PIN, value);
	// Write the value received to the digital pin.
	digitalWrite(ACTUATOR_PIN, value);
}

next you need to have global boolean state for the weighing.

bool weight = false;
if( wieght data > 10){
    weight = true
}

now combine both

CAYENNE_IN(VIRTUAL_CHANNEL)
{
	int value = getValue.asInt();
	CAYENNE_LOG("Channel %d, pin %d, value %d", VIRTUAL_CHANNEL, ACTUATOR_PIN, value);
	// Write the value received to the digital pin.
        if(weight){
	digitalWrite(ACTUATOR_PIN, value);
        }
}