naveen manwani
Published © GPL3+

Using Grove Button To Control Grove LED

How to connect and use Grove Button to control Grove LED socket kit.

BeginnerShowcase (no instructions)10 hours3,104
Using Grove Button To Control Grove LED

Things used in this project

Hardware components

Arduino 101
Arduino 101
×1
Seeed Studio grove starter kit for arduino/genuino101
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

connection of LED socket kit on Grove Base Shield

it will show the connection of led socket kit on pin D7 over Grove Base Shield

connection of Grove_Button on Grove Base Shield

connecting Grove Button on pin D3 over Grove Base Shield which is mounted on Arduino/Genuino 101

complete connection setup

Working setup

Code

To control Grove_LED socket kit through Grove_Button

C/C++
// this demo will show you how to use Grove - Button to control a LED
// when the button was pressed, the led will on 
// otherwise led off
// Grove - Button connect to D3
// Grove - LED connect to D7

const int pinButton = 3;                        // pin of button define here
const int pinLed    = 7;                        // pin of led define here

void setup()
{
    pinMode(pinButton, INPUT);                  // set button INPUT
    pinMode(pinLed, OUTPUT);                    // set led OUTPUT
}

void loop()
{
    if(digitalRead(pinButton))                     // when button is pressed
    {
        digitalWrite(pinLed, HIGH);             // led on
    }
    else
    {
        digitalWrite(pinLed, LOW);
    }
    
    delay(10);
}

Credits

naveen manwani

naveen manwani

9 projects • 9 followers
Electronics & Communication Engineer,machine learning and deep learning enthusiast |Fast.ai Fellowship,Mentor @ coursera deeplearning.ai

Comments