Im gradually learning how to use arduino and have gone through a few tutorials, however I am having problems getting the Neopixel 16 LED ring to work.
I want to make this arduino lie detector or similar: http://www.erobotkits.com/arduino-proje ... -detector/
this defines the LEDs as pins, which makes sense but as the whole Neopixel is only attached to one pin, I can not get this to work. I have tried including # the library at the top of the code but still no luck
My question: How do I replace the
Code: Select all
int red_Pin = 9;
int green_Pin = 10;
int blue_Pin = 11;
int buzzer_Pin = 7;
The rest of the code is below
Code: Select all
int red_Pin = 9;
int green_Pin = 10;
int blue_Pin = 11;
int buzzer_Pin = 7;
int pot_Pin = 1;
int sensor_Pin = 0;
long red = 0xFF0000;
long green = 0x00FF00;
long blue = 0×000080;
int band = 10;
void setup()
{
pinMode(pot_Pin, INPUT);
pinMode(sensor_Pin, INPUT);
pinMode(red_Pin, OUTPUT);
pinMode(green_Pin, OUTPUT);
pinMode(blue_Pin, OUTPUT);
pinMode(buzzer_Pin, OUTPUT);
}
void loop()
{
int gsr = analogRead(sensor_Pin);
int pot = analogRead(pot_Pin);
if (gsr > pot + band)
{
setColor(red);
beep();
}
else if (gsr < pot – band)
{
setColor(blue);
}
else
{
setColor(green);
}
}
void setColor(long rgb)
{
int red = rgb >> 16;
int green = (rgb >> 8) & 0xFF;
int blue = rgb & 0xFF;
analogWrite(red_Pin, 255 – red);
analogWrite(green_Pin, 255 – green);
analogWrite(blue_Pin, 255 – blue);
}
void beep()
{
// 5 Khz for 0.2 second
for (int i = 0; i < 1000; i++)
{
digitalWrite(buzzer_Pin, HIGH);
delayMicroseconds(100);
digitalWrite(buzzer_Pin, LOW);
delayMicroseconds(100);
}
}
Thanks