// Includes the library code
#include <LiquidCrystal.h>
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
#define PIN 6
#define NUMPIXELS 3
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define DELAYVAL 500
// Defines the LCD's parameters: (rs, enable, d4, d5, d6, d7)
LiquidCrystal lcd(9, 8, 5, 4, 3, 2);
int red;
int green;
int blue;
int pixelNum;
void setup() {
clock_prescale_set(clock_div_1);
pixels.begin();
// Set up the LCD's number of columns and rows
lcd.begin(16, 2);
pixelNum = 0;
}
int getValueRescaleInt(int value, int maxValue) {
return int(float(value) / 1023 * maxValue);
}
float getValueRescalefloat(int value, int maxValue) {
return float(value) / 1023 * maxValue;
}
void loop() {
pixelNum = (pixelNum + 1) % NUMPIXELS;
red = getValueRescaleInt(analogRead(A0), 255);
green = getValueRescaleInt(analogRead(A1), 255);
blue = getValueRescaleInt(analogRead(A2), 255);
lcd.setCursor(0,0);
lcd.print(pixelNum);
lcd.setCursor(0,1);
lcd.print(String("RGB (" + String(red) + "," + String(green) + "," + String(blue) + ")"));
pixels.setPixelColor(pixelNum, pixels.Color(red, green, blue));
pixels.show();
delay(500);
lcd.clear();
}