Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Published

Simple LED On/Off Circuit

A simple 13 LED on/off circuit utilizing the extra pins on the Arduino Mega 2560.

BeginnerShowcase (no instructions)2,381
Simple LED On/Off Circuit

Things used in this project

Story

Read more

Schematics

Button Diagram

It is a diagram of the button circuit, this does not include the LED's

Code

Mega2560 LED Test

C/C++
A code file for this project
// Advanced LED Light Show
// Written by Treebug842

int buttonstate = 0;
const int led1 = 22;
const int led2 = 24;
const int led3 = 26;
const int led4 = 28;
const int led5 = 30;
const int led6 = 32;
const int led7 = 34;
const int led8 = 36;
const int led9 = 38;
const int led10 = 40;
const int led11 = 42;
const int led12 = 44;
const int red = 2;
const int green = 3;
const int blue = 4;

void setup() {
pinMode(22, OUTPUT);
pinMode(24, OUTPUT);
pinMode(26, OUTPUT);
pinMode(28, OUTPUT);
pinMode(30, OUTPUT);
pinMode(32, OUTPUT);
pinMode(34, OUTPUT);
pinMode(36, OUTPUT);
pinMode(38, OUTPUT);
pinMode(40, OUTPUT);
pinMode(42, OUTPUT);
pinMode(44, OUTPUT);
pinMode(52, INPUT);
}

void loop() {
buttonstate = digitalRead(52); {
if (buttonstate == HIGH) {
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led8, HIGH);
digitalWrite(led9, HIGH);
digitalWrite(led10, HIGH);
digitalWrite(led11, HIGH);
digitalWrite(led12, HIGH);
delay(1000);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
digitalWrite(led9, LOW);
digitalWrite(led10, LOW);
digitalWrite(led11, LOW);
digitalWrite(led12, LOW);
    }
  }
}

Credits

Comments