Arnov Sharma
Published © CC BY

Freeform Button and LED ON OFF tutorial

It's a tutorial but with freeform circuitry components.

BeginnerFull instructions provided3 minutes844
Freeform Button and LED ON OFF tutorial

Things used in this project

Story

Read more

Schematics

buttonfgf_OlDXB0pJYY.png

Code

Untitled file

C/C++
const int buttonPin = 4; 
const int GREEN =  3;
const int RED =  2;

int buttonState = 0;  
 
void setup() {
  pinMode(GREEN, OUTPUT);
  pinMode(RED, OUTPUT);
  pinMode(buttonPin, INPUT); 
}


void loop() {
   buttonState = digitalRead(buttonPin);
    if (buttonState == HIGH) {
      digitalWrite(GREEN,HIGH);
      digitalWrite(RED,LOW);
      
    } else {
    
    digitalWrite(RED, HIGH);
    digitalWrite(GREEN, LOW);
}
}

Credits

Arnov Sharma
353 projects • 360 followers
I'm Arnov. I build, design, and experiment with tech—3D printing, PCB design, and retro consoles are my jam.

Comments