/***************************************************************
To arduino uno attached neopixel ring via pin 6 with
12 led write a code in such a way that first led blinkd once
second twicce third trice and so on with random color
This code uses the Adafruit_NeoPixel library to control the
NeoPixel ring. It sets the color of each LED to a random RGB
value, and then blinks the LED i+1 times (e.g., the first LED
blinks once, the second LED blinks twice, etc.) using a loop.
The delay() function is used to control the duration of
each blink.
AUTHOR ARVIND PATIL 12 MAY 2023
The code now includes the necessary libraries for the LCD display
(Wire.h and LiquidCrystal_I2C.h). Inside the setup() function,
the LCD is initialized with the I2C address and dimensions,
and the backlight is turned on.
Inside the loop, the code prints the serial messages as before,
but now it also clears the LCD display using the lcd.clear()
function and sets the cursor to the top left corner using
lcd.setCursor(0, 0). The message is then printed on the
LCD using the lcd.print() function.
Note that the LCD display must be connected to the Arduino
via I2C (pins A4 and A5 on the Uno). Also, make sure to adjust
the contrast on the LCD using the potentiometer on the back
of the module, if necessary.
****************************************************************/
#include <Wire.h>
#include <Adafruit_NeoPixel.h>
#include <LiquidCrystal_I2C.h>
#define LED_PIN 6
#define LED_COUNT 12
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
LiquidCrystal_I2C lcd(0x27, 20, 4); // Set the LCD address to 0x27 for a 20x4 display
void setup() {
Serial.begin(9600);
lcd.init(); // Initialize the LCD display
lcd.backlight(); // Turn on the LCD backlight
strip.begin();
strip.show();
}
void loop() {
for (int i = 0; i < LED_COUNT; i++) {
lcd.clear(); // Clear the LCD display
lcd.setCursor(0, 0); // Set the cursor to the top-left corner
lcd.print("this Blinks ");
lcd.print(i+1);
lcd.print(" times");
lcd.setCursor(0, 1);
lcd.print("project by arvind ");
Serial.print("Blink ");
Serial.print(i+1);
Serial.println(" times");
lcd.setCursor(0, 2);
lcd.print("blink frequency ");
lcd.setCursor(0, 3);
lcd.print("postion no of led ");
for (int j = 0; j < i+1; j++) {
strip.setPixelColor(i, random(256), random(256), random(256));
strip.show();
delay(100);
}
delay(500);
}
}