Clicky

Loading

MakerBot Print is our newest print-prepration software, which supports native CAD files and STL assemblies,
allows you to interact with all your printers via the Cloud, and many other exciting new features.

Download Now

Report as inappropriate

I am working to make a dual push button program to actuate a can crusher for my kid so that he won't crush his little fingers. I have already created a functioning code but would like to make it so that if either button (or statement) is held down too long the output will turn off, the code below takes both buttons to turn on the output and if either button is released the output turns off. I just don't want him to get smart enough to tape/block one button on so that he only has to use one button to actuate the crusher potential crushing his hand instead of the can. Any help with this would be appreciated

int left = 2;
int right = 3;
int crush = 8;
int pbLeft = 0;
int pbRight = 0;

void setup() {
// put your setup code here, to run once:
pinMode (left, INPUT);
pinMode (right, INPUT);
pinMode (crush , OUTPUT);
Serial.begin (9600);

}

void loop() {
// put your main code here, to run repeatedly:

pbLeft = digitalRead(left);
pbRight = digitalRead(right);

if (pbLeft == HIGH && pbRight == HIGH){
digitalWrite(crush,HIGH);
}

if (pbLeft == LOW || pbRight == LOW){
digitalWrite(crush, LOW);
}

}