Skip to content

Instantly share code, notes, and snippets.

@futureshocked
Last active July 30, 2019 01:00
Show Gist options
  • Save futureshocked/c0ecc83ca188c70878ec8c48415ca9b6 to your computer and use it in GitHub Desktop.
Save futureshocked/c0ecc83ca188c70878ec8c48415ca9b6 to your computer and use it in GitHub Desktop.
This sketch demonstrates how to use the Grove relay module.
/* 05.50 - Grove Relay module
*
This sketch demonstrates how to use the Grove relay module.
This sketch is identical to the one from 05.10, that we used with the
LED kit module. We'll use a digital pin to energise the relay coil, and
drive a large electrical load.
The load can be anything the draws less than 10A current and 30V.
For example, you can drive a fan, an LED strip, or an electro-magnet.
Connect the relay module to Grove connector D4.
Connect the electrical load to the screw terminal of the relay board, like
a switch. Please watch the video in lecture 05.50 for a demonstration on
how to do this.
Components
----------
- Grove Base Shield
- An Arduino Uno compatible board (such as Arduino/Genuino Uno or Seeeduino)
- Grove LED relay module
- An electrical load, such as an LED strip, and its external power supply.
- One Grove cable
IDE
---
Arduino IDE
Libraries
---------
-
Connections
-----------
Use a Grove cable to connect the module to Base Shield connector D4.
Other information
-----------------
- Use this sketch along side the video lecture 05.50 of Grove For Busy People
- Grove component: https://txplo.re/7fb98
Github Gist
-----------
<script src="https://gist.github.com/futureshocked/c0ecc83ca188c70878ec8c48415ca9b6.js"></script>
https://gist.github.com/futureshocked/c0ecc83ca188c70878ec8c48415ca9b6
For course information, please go to https://techexplorations.com/product/grove-for-busy-people/
Created on July 5 2019 by Peter Dalmaris
*/
const int ledPin = 4;
// Connect the LED to Arduino digital pin 4, Grove socket D4
void setup() {
// initialize ledPin as an output.
pinMode(ledPin, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment