Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IoT-Spot : LED Blinking using RaspberryPI #351

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <Adafruit_NeoPixel.h>

#define PIN_R 1 // Replace with the GPIO pin for the Red LED
#define PIN_G 2 // Replace with the GPIO pin for the Green LED
#define PIN_B 3 // Replace with the GPIO pin for the Blue LED
#define NUM_LEDS 1

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN_R, NEO_GRB + NEO_KHZ800);

void setup() {
strip.begin();
strip.show();
}

void loop() {
// Turn on Red LED
colorWipe(strip.Color(255, 0, 0), 50); // Red
delay(500);

// Turn on Green LED
colorWipe(strip.Color(0, 255, 0), 50); // Green
delay(500);

// Turn on Blue LED
colorWipe(strip.Color(0, 0, 255), 50); // Blue
delay(500);
}

void colorWipe(uint32_t color, int wait) {
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, color);
strip.show();
delay(wait);
}
}
75 changes: 75 additions & 0 deletions ESP8266/Basic RGB LED Blinking Using ESP8266/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# ESP8266 RGB LED Blinking Project


## Aim

The main aim of this project is to demonstrate how to control an RGB LED using an ESP8266 microcontroller.

## Purpose

The purpose of this project is to provide a simple example of RGB LED control with an ESP8266, suitable for educational and learning purposes.


## Components Required

- ESP8266 microcontroller (NodeMCU)
- RGB LED
- Breadboard and jumper wires


## Short description of package/script

This Arduino script controls an RGB LED connected to an ESP8266 microcontroller. It uses the Adafruit NeoPixel library to cycle through red, green, and blue colors with adjustable speed.

- IDE: Arduino IDE
- Library: Adafruit NeoPixel


## Workflow of the Project

1. Initialize the NeoPixel strip.
2. Cycle through red, green, and blue colors with a delay between each color change.
3. Adjust the speed of color transitions by changing the `wait` value in the `colorWipe` function.


## Setup instructions

1. Connect the common cathode of the RGB LED to the ground (GND) pin on the ESP8266.
2. Connect each RGB LED anode (R, G, B) to different GPIO pins on the ESP8266 (e.g., D1, D2, D3).
4. Open the Arduino IDE and ensure ESP8266 board support is installed.
4. Include the Adafruit NeoPixel library.
5. Copy the provided code into the Arduino IDE.
6. Replace placeholder values with actual GPIO pins.
7. Upload the code to the ESP8266.

## Detailed explanation of script

The script uses the Adafruit NeoPixel library to control the RGB LED. The `colorWipe` function fills the LED with a specified color, creating a visual effect.

```
void colorWipe(uint32_t color, int wait) {
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, color);
strip.show();
delay(wait);
}
}
```


## Compilation Steps

1. Open Arduino IDE.
2. Set the board to ESP8266.
3. Include the Adafruit NeoPixel library.
4. Copy and paste the code.
5. Replace placeholder values.
6. Upload the code to the ESP8266.

## Disclaimer

Before you start making any connections please disconnect the device from your laptop/workstation so there is no power getting to the device. You should never make any connection changes when the device is powered on.

## Author(s)

[MUKUND SOLANKI](https://github.com/mukundsolanki)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions Raspberry Pi/Blink_The_LED/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# LED Blinking using RaspberryPI

## Aim
LED Blinking using RaspberryPI

## Purpose
LED Blinking using RaspberryPI

**Requirements:**
- Rasberry-Pi
- Bread-Board
- Jumper-Wires
- LED
---
## Workflow of the Project

- Upon starting the circuit, the GPIO pins are configured to control the LED.
- The program enters a loop, turning the LED on and off at regular intervals.

## Setup Instructions
- Connect the cathode (short leg) of the LED to a GPIO pin on the Raspberry Pi.
- Connect the other end of the resistor to any GND (ground) pin on the Raspberry Pi.
Run the provided code on the Raspberry Pi.

## Author:
<a href="https://github.com/mukundsolanki">Mukund Solanki</a>
24 changes: 24 additions & 0 deletions Raspberry Pi/Blink_The_LED/blink_led.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import time
from gpiozero import LED

# Set the GPIO pin according to your setup
led = LED(17)

def blink_led(interval_seconds, duration_seconds):
start_time = time.time()
end_time = start_time + duration_seconds

while time.time() < end_time:
led.on()
time.sleep(interval_seconds / 2)
led.off()
time.sleep(interval_seconds / 2)

if __name__ == "__main__":
# Set the interval and duration
blink_interval = 2 # seconds
blink_duration = 10 # seconds

print(f"Blinking LED every {blink_interval} seconds for {blink_duration} seconds")

blink_led(blink_interval, blink_duration)
4 changes: 4 additions & 0 deletions Raspberry Pi/Blink_The_LED/requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1) Rasberry-Pi
2) Bread-Board
3) Jumper-Wires
4) LED