I'm new to the whole digit circuit design. I am building a circuit with the Arduino to run a pneumatic actuator after a button is pressed a set amount of time. I have all the code complete for the count, but I want to be able to control the pneumatic actuator outside of the program. I want to create a momentary button that will change the state of the actuator. Basically I need a single clock input that changes the state of the output. What type of IC would I use for that? Thanks
You don't need an extra IC, the Arduino can do what you want.
You do need a driver module for the actuator.
I assume that you mean that you want to activate an actuator to run through some cycle (time or position sensitive), but that you would like to be able to stop the actuator independently of the program. The easiest way to do that is to use an interrupt pin: that will stop whatever the main loop() is doing, and jump off to execute the code attached to the interrupt.
jrdoner:
The easiest way to do that is to use an interrupt pin: that will stop whatever the main loop() is doing, and jump off to execute the code attached to the interrupt.
Bad advice. Just make the code non-blocking and you can just poll the button.
Yeah, is the time is set with a delay you can stop it in a interrupt but after that the delay will go on and block the rest...
@shark38j, just post your code. You don't need any extra IC to do what you want, you just need better code
Thanks everyone. The link to my project at 123D Circuit and the code are below.
//Machine Counter
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,4,5,6,7);
int stockQty = 5; //Stockup Quantity to Change
int pusherButton = 12;
int solenoid = 11;
int partCount = 0 ;
void setup()
{
pinMode(pusherButton, INPUT);
pinMode(solenoid, OUTPUT);
Serial.begin(9600);
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Stockup Qty:");
lcd.setCursor(12,0);
lcd.print(stockQty);
lcd.setCursor(0,1);
lcd.print("Part Count:");
}
void counter()
{
partCount++;
lcd.setCursor(12,1);
lcd.print(partCount);
delay(1000);
}
void complete()
{
digitalWrite(solenoid, HIGH);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Stockup Complete");
lcd.setCursor(0,1);
lcd.print("Push Reset --->");
delay(2000);
digitalWrite(solenoid, LOW);
while(1){}
}
void loop()
{
while(digitalRead(pusherButton)!=HIGH){}
if(partCount >= stockQty)
{
complete();
}
counter();
}
It is not clear what kind of time period are we talking about?
Days, hours, minutes seconds?
Dwight
int swtich = 13;
volatile int state = LOW;
void setup() {
pinMode(switch, INPUT);
attachInterrupt(0, blink, CHANGE); // actuator will be on pin2 if using arduino uno
}
void loop() {
if(digitalRead(switch) == HIGH)
{
count++;
}
if(count == number of times needed)
{
Actuator = 1;
}
}
void blink() {
actuator = 1;
}
USE Code Tags Please.
nt swtich = 13;
volatile int state = LOW;
void setup() {
pinMode(switch, INPUT);
attachInterrupt(0, blink, CHANGE); // actuator will be on pin2 if using arduino uno
}
void loop() {
if(digitalRead(switch) == HIGH)
{
count++;
}
if(count == number of times needed)
{
Actuator = 1;
}
}
void blink() {
actuator = 1;
}
Thanks everyone. I did some research on attachInterrupt() and got it up and running. That will help a lot with the rest of my project.
jrdoner:
The easiest way to do that is to use an interrupt pin: that will stop whatever the main loop() is doing, and jump off to execute the code attached to the interrupt.
Extremely bad advice.
shark38j:
Thanks everyone. I did some research on attachInterrupt() and got it up and running.
Problem is, while it may appear to work so far, you now have code that cannot be enhanced with other functions.
Oh well ...