###Arduino pin connected to button's pin###

Take the time and tell us a little about yourself

Moderators: BOBLOOK, AE25, pufito18

Post Reply
BOBLOOK
Posts: 2327
Joined: Wed Jun 19, 2013 7:32 pm
Location: Under a bonned in Netherlands.

###Arduino pin connected to button's pin###

Post by BOBLOOK »

No it's not 3tc related but since you fellas are not using the forum i use it for some junk lol

/*
* Created by ArduinoGetStarted.com
*
* This example code is in the public domain
*
* Tutorial page: https://arduinogetstarted.com/tutorials ... tton-relay
*/

const int BUTTON_PIN = 2; // Arduino pin connected to button's pin
int yellow = 10;
int red = 12;
int green = 11;
int red2 = 9;
int green2 = 8;

void setup() {
Serial.begin(9600);
pinMode(BUTTON_PIN, INPUT); // set arduino pin to input pull-up mode

pinMode(yellow, OUTPUT);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(red2, OUTPUT);
pinMode(green2, OUTPUT);
}

void loop() {
int buttonState = digitalRead(BUTTON_PIN); // read new state





if ((buttonState != digitalRead,red) && (buttonState == HIGH)){
delay(1000);
Serial.println("The button is being pressed");
digitalWrite(red2, HIGH);


digitalWrite(yellow, LOW);
digitalWrite(red, HIGH);
delay(1000);
digitalWrite(red2, LOW);
digitalWrite(green2, HIGH);
delay(2000);
digitalWrite(green2, LOW);
delay(200);
digitalWrite(green2, HIGH);
delay(200);
digitalWrite(green2, LOW);
delay(200);
digitalWrite(green2, HIGH);
delay(200);
digitalWrite(green2, LOW);
delay(200);
digitalWrite(green2, HIGH);
delay(200);
digitalWrite(green2, LOW);
delay(200);
digitalWrite(green2, HIGH);
delay(230);
digitalWrite(green2, LOW);
delay(270);
digitalWrite(green2, HIGH);
delay(300);
digitalWrite(green2, LOW);
delay(1000);
digitalWrite(red2, HIGH);


}

if (buttonState == LOW) {

Serial.println("The button is unpressed");


digitalWrite(yellow, LOW);
digitalWrite(green, LOW);
digitalWrite(red, HIGH);
delay(3000);
digitalWrite(yellow, LOW);
digitalWrite(green, HIGH);
digitalWrite(red, LOW);
delay(2000);
digitalWrite(yellow, HIGH);
digitalWrite(green, LOW);
digitalWrite(red, LOW);
delay(2000);
}
}
The day we learn to think
Post Reply