Im doing a senior design project for my engineering program with a team of four people. Basically we are creating an automated compression cuff for medical purposes. We are using an arduino uno to control a solenoid, a LCD display, a momentary foot switch, and read a pressure sensor. Im having trouble with the loop part of the code with the foot switch. In this code we are using an LEDpin to mimic our solenoid. The solenoid will only open (because it is normally closed) when the foot switch is depressed. In this mock up, the opening of the solenoid is the LEDpin lighting up. Now the pin cannot light up if the pressure is too high. For our purposes the solenoid will only operate within a specified range. So, I want the solenoid to OPEN (LEDpin lighted up) for 5 seconds only when the foot swtich is depressed. BUT i want the foot switch to only open the solenoid for 5 seconds, NO MATTER how long the foot switch is depressed. Once the 5 seconds elapse, and the foot switch is released or not released there should be a delay before it is depressed again to do another 5 seconds. How do i implement this?
We are using an arduino uno to control ... a momentary foot switch
Exactly how are you controlling the foot switch?
In this code we are using an LEDpin to mimic our solenoid.
I doubt that. You might be using an LED to mimic the solenoid.
BUT i want the foot switch to only open the solenoid for 5 seconds, NO MATTER how long the foot switch is depressed. Once the 5 seconds elapse, and the foot switch is released or not released there should be a delay before it is depressed again to do another 5 seconds. How do i implement this?
The state change detection example will show you how to determine that the switch has become pressed or has become released.
The blink without delay example will show you how you can turn the pin on when some event occurs, and turn it off a specific time later, without the need to block the whole code for the time that the solenoid is supposed to be active.
@PaulS we are using the foot switch to open the solenoid, meaning give it power, which the LED simulates in our mock up so far (LED is used for ON/OFF like the solenoid). When the foot switch is depressed, the LED lights up and stays on as long as the foot switch is depressed. We don't want that; we want the LED (solenoid) to stay on (open) for only 5 seconds then shut off (close, LED OFF). After that, there has to be a delay of 1 second before we can press the foot switch again to successfully repeat the cycle. The foot switch is controlled with an analog pin and power, two wires.
So the state change detection example along with blink without delay example will solve this?
Additional info: the pressure sensor used is from freescale semi-conductor, it has been calibrated and reads the correct atmospheric pressure. There will be an air line going to one nozzle of the sensor to read the pressure difference. In emergency cases, the foot switch cannot work (meaning solenoid cant open) if the pressure detected is too high. A mini air compressor supplies the air with regulator, but is not part of the arduino system.
jimbo1326:
Im doing a senior design project for my engineering program with a team of four people.
Basically we are creating an automated compression cuff for medical purposes.
We are using an arduino uno to control a solenoid, a LCD display, a momentary foot switch, and read a pressure sensor.
Im having trouble with the loop part of the code with the foot switch.
In this code we are using an LEDpin to mimic our solenoid.
The solenoid will only open (because it is normally closed) when the foot switch is depressed.
In this mock up, the opening of the solenoid is the LEDpin lighting up.
Now the pin cannot light up if the pressure is too high.
For our purposes the solenoid will only operate within a specified range.
So, I want the solenoid to OPEN (LEDpin lighted up) for 5 seconds only when the foot swtich is depressed.
BUT i want the foot switch to only open the solenoid for 5 seconds, NO MATTER how long the foot switch is depressed.
Once the 5 seconds elapse, and the foot switch is released or not released there should be a delay before it is depressed again to do another 5 seconds.
How do i implement this?
jimbo1326: @PaulS we are using the foot switch to open the solenoid, meaning give it power, which the LED simulates in our mock up so far (LED is used for ON/OFF like the solenoid).
When the foot switch is depressed, the LED lights up and stays on as long as the foot switch is depressed.
We don't want that; we want the LED (solenoid) to stay on (open) for only 5 seconds then shut off (close, LED OFF).
After that, there has to be a delay of 1 second before we can press the foot switch again to successfully repeat the cycle.
The foot switch is controlled with an analog pin and power, two wires.
So the state change detection example along with blink without delay example will solve this?
Additional info: the pressure sensor used is from freescale semi-conductor, it has been calibrated and reads the correct atmospheric pressure.
There will be an air line going to one nozzle of the sensor to read the pressure difference. In emergency cases, the foot switch cannot work (meaning solenoid cant open) if the pressure detected is too high.
A mini air compressor supplies the air with regulator, but is not part of the arduino system.
thanks for quick replies.
Sorry, but just couldn't concentrate trying to read it, can you read back any of your posts before posting them please?
To help us understand your project, can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Thanks.. Tom..
Hint, you donot want to detect when the switch is ON, you need to detect when it is SWITCHED from OFF to ON, then instigate a timer.