Hello I would like to seek help on coding. I can create code on vibration once a pressure is detected. However, I would like to create a code that vibration occur when pressure exists for a preset duration(10mins), instead of a immediate stimulation. Urgent help is needed and thank you!
Code that I got:
//Arduino to I/O for RAPID, ABB control
int pressPin = 0; //pressure sensor to Arduino A0
int initReading; //variable for the initial reading,
// of the pressure sensor.
int reading; //variable for storing current pressure
//reading
boolean startUp; //sets up a calibration ‘switch’
int di1Pin = 9; //sends signal to robot controller
void setup()
{
//Serial.begin(9600); //Setup a serial connection for debug.
initReading = 0; //Initialize initReading.
reading = analogRead(pressPin); //Reading equals the value,
//returned by the sensor.
startUp = true; //Initialize the calibration switch to ‘on’
pinMode(di1Pin, OUTPUT); //Pin 9 is set to SEND a signal.
}
void loop()
{
calibrate(); //calls the function defined below
reading = analogRead(pressPin); //Reading equals the value,
//from the sensor
if(reading < initReading*.9) //If reading is less than 90%,
{ //of the initial sensor value,
digitalWrite(di1Pin, HIGH); //send a signal to the controller.
}
else
{
digitalWrite(di1Pin,LOW); //send no signal
}
}
void calibrate() //The first thing to do in the loop,
{
if(startUp == true) //if the calibration switch is on (which it is),
{
initReading = reading; //set initReading equal to the sensor
//value.
startUp = false; //And shut of the calibration switch.
}
}//Arduino to I/O for RAPID, ABB control
int pressPin = 0; //pressure sensor to Arduino A0
int initReading; //variable for the initial reading,
// of the pressure sensor.
int reading; //variable for storing current pressure
//reading
boolean startUp; //sets up a calibration ‘switch’
int di1Pin = 9; //sends signal to robot controller
void setup()
{
//Serial.begin(9600); //Setup a serial connection for debug.
initReading = 0; //Initialize initReading.
reading = analogRead(pressPin); //Reading equals the value,
//returned by the sensor.
startUp = true; //Initialize the calibration switch to ‘on’
pinMode(di1Pin, OUTPUT); //Pin 9 is set to SEND a signal.
}
void loop()
{
calibrate(); //calls the function defined below
reading = analogRead(pressPin); //Reading equals the value,
//from the sensor
if(reading < initReading*.9) //If reading is less than 90%,
{ //of the initial sensor value,
digitalWrite(di1Pin, HIGH); //send a signal to the controller.
}
else
{
digitalWrite(di1Pin,LOW); //send no signal
}
}
void calibrate() //The first thing to do in the loop,
{
if(startUp == true) //if the calibration switch is on (which it is),
{
initReading = reading; //set initReading equal to the sensor
//value.
startUp = false; //And shut of the calibration switch.
}
}
The above code can create vibration once pressure is detected. But I don't know where and how to add the part to count pressure time before vibration occurs.T-T