Site Overlay

Simple led, button with Arduino using Serial

As Arduino is becoming popular among students or enthusiasts in different interesting projects. Many students are learning the programming and use of Arduino. This post will explain all the basics about programming the Arduino using simple led button with Arduino using Serial monitoring it. It consists of five different projects to test out different techniques and uses of Arduino,

What you need for these simple 5 Projects

  • An Arduino uno or Clone.
  • 3mm 5mm or 10mm Leds any will work and 1 RGB led.
  • Some Push Buttons.
  • A breadboard.
  • Male to Male Jumper Wires.
  • Some 10k and 220 Resistors.
  • 10 led bar graph or leds will work

Step 1: Push Button and the Serial Monitor.

Picture of Push Button and the Serial Monitor.

If you put this code into your Arduino , when you open the serial monitor and push the button it will come up as 1.

int button1 = 7;
void setup(){
void loop(){
Serial.println( );
if(digitalRead(BUTTON1) == HIGH)
Serial.println("Button1 1");
Serial.println("Button1 0");
} delay(200);

Step 2: 1 Button 1 Led.

Picture of 1 Button 1 Led.
int LED = 13;
int BUTTON = 2;
void setup(){
void loop(){
if(digitalRead(BUTTON) == HIGH){

this code will make it so when you push the button the led will light up.

Step 3: 3 Buttons and RGB LED.

Picture of 3 Buttons and RGB LED.

this code should make it so when you push one button one color should light up if you push all three buttons it will make a whitish color.

int BUTTON1 = 9; 
int BUTTON2 = 10;
int BUTTON3=11;
int BLUE=3;
int GREEN=5;
int RED=6;</p><p>void setup(){</p><p>pinMode(BUTTON1,INPUT); pinMode(BUTTON2,INPUT);
}</p><p>void loop(){
if(digitalRead(BUTTON1) == HIGH){
if(digitalRead(BUTTON2) == HIGH){
if(digitalRead(BUTTON3) == HIGH){

Step 4: Led Pin 13 and Serial Monitor.

Picture of Led Pin 13 and Serial Monitor.
int outPin = 13;
void setup(){
Serial.println("Enter 1 or 0");
void loop(){
char ch =;
if (ch == '1')
else if (ch == '0')
this code will make it so when you go into the serial monitor and type 1 the led on pin 13 will light up then when you type 0 the led will be off.

Step 5: Random Number Generator With Led Bar Graph.

Picture of Random Number Generator With Led Bar Graph.
Picture of Random Number Generator With Led Bar Graph.
int LED0 = 2;
int LED1 = 3;
int LED2 = 4;
int LED3 = 5;
int LED4 = 6;
int LED5 = 7;
int LED6 = 8;
int LED7 = 9;
int LED8 = 10;
int LED9 = 11;
long randomNumber;
void setup() {
Serial.println("Randon Numbernesssssss");
pinMode(LED0, OUTPUT);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
pinMode(LED7, OUTPUT);
pinMode(LED8, OUTPUT);
pinMode(LED9, OUTPUT);
randomSeed( analogRead(A0) );
void loop() {
randomNumber = random(2,12);
This code will make it so when you connect the led or the bar graph to the Arduino it will make random numbers, and the number it makes is the pin number on the Arduino. Say something if you need help with anything.

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2020 DIY Projects Arduino Crafts. All Rights Reserved. | Foodoholic by Catch Themes