KieranP21
Published © GPL3+

LED Indicator for Your Robot / Machine

This little project is just for the beginners showing them how to link buttons to LEDs to control their state.

BeginnerFull instructions provided874
LED Indicator for Your Robot / Machine

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×1
Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×12
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Green
5 mm LED: Green
×1
Elegoo Tactile Button Switch Push To Close
×1

Story

Read more

Schematics

BreadBoard Plans

Shows you exactly how to connect up the parts (Easy to understand)

Schematics

If you understand how to read this then i have also included the schematic for you

Code

Button Activation Code

Arduino
The system has a go button a stop button and a reset button when the go button is clicked the green led is on showing that it is operational when the stop button is pressed the led goes off displaying a red led to show it has stopped and the rest button kills everything
const int LED_GREEN = 13;       //Giving Pin 13 the name of LED_GREEN
const int BTN_GO = 2;        //Giving Pin 2 the name of BTN_ON
const int LED_RED = 12;       //Giving Pin 12 the name of LED_RED
const int BTN_STOP = 4;      //Giving Pin 4 the name of BTN_OFF
const int BTN_RESET = 7;
int btn_state1 = 0;       //Declaring the Button State variable 
int btn_state2 = 0;
int btn_state3 =0;
void setup() {
  // put your setup code here, to run once:
  pinMode(LED_GREEN, OUTPUT);      //Setting Pin 13 as an OUTPUT
  pinMode(BTN_GO, INPUT);       //Setting Pin 2 as an INPUT
  pinMode(LED_RED, OUTPUT);       //Setting Pin 12 as an OUTPUT
  pinMode(BTN_STOP, INPUT);
  pinMode(BTN_RESET, INPUT);
  digitalWrite(BTN_GO, HIGH);
  digitalWrite(BTN_STOP, HIGH);
  digitalWrite(BTN_RESET, HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
  btn_state1 = digitalRead(BTN_GO);
  btn_state2 = digitalRead(BTN_STOP);
  btn_state3 = digitalRead(BTN_RESET);
  
  //Once button has been pressed LED stays ON
  if (btn_state1 == LOW)
  {
    digitalWrite(LED_GREEN, HIGH);
    digitalWrite(LED_RED, LOW);
  } 
  if (btn_state2 == LOW){
    digitalWrite(LED_GREEN, LOW);
    digitalWrite(LED_RED, HIGH);
  }
  if (btn_state3 == LOW)
  {
    digitalWrite(LED_GREEN, LOW);
    digitalWrite(LED_RED, LOW);
  }
}

Credits

KieranP21
1 project • 0 followers

Comments