loading

Arduino Code?

int redPin = 9;
int greenPin = 10;
int bluePin = 11;

int buzzerPin = 7;

int potPin = 1;
int sensorPin = 0;

long red = 0xFF0000;
long green = 0x00FF00;
long blue = 0x000080;

int band = 10;
// adjust for sensitivity

void setup()
{
  pinMode(potPin, INPUT);
  pinMode(sensorPin, INPUT);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
}
void loop()
{
    int gsr = analogRead(sensorPin);
    int pot = analogRead(potPin);
    if (gsr > pot + band)
    {
        setColor(red);
        beep();
    }
    else if (gsr > 16;
    int green = (rgb >> 8) & 0xFF;
    int blue = rgb & 0xFF;
    analogWrite(redPin, red);
    analogWrite(greenPin, green);
    analogWrite(bluePin, blue);
}

void beep()
{
    for (int i=0; i<1000; i++)
    {
        digitalWrite(buzzerPin, HIGH);
        delayMicroseconds(100);
        digitalWrite(buzzerPin, LOW);
        delayMicroseconds(100);
    }
}

The code does not compile properliy it says steColour was not defined in the scope.Its a lie detector code.

Bot13985 years ago
int redPin = 9;
int greenPin = 10;
int bluePin = 11;

int buzzerPin = 7;

int potPin = 1;
int sensorPin = 0;

long red = 0xFF0000;
long green = 0x00FF00;
long blue = 0x000080;

int band = 15;
// adjust for sensitivity

void setup()
{
pinMode(potPin, INPUT);
pinMode(sensorPin, INPUT);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
}
void loop()
{
int gsr = analogRead(sensorPin);
int pot = analogRead(potPin);
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(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}

void beep()
{
for (int i=0; i<1000; i++)
{
digitalWrite(buzzerPin, HIGH);
delayMicroseconds(100);
digitalWrite(buzzerPin, LOW);
delayMicroseconds(100);
}
}

I modified the code a little now it compiles SUCCESSFULLY
+1.

When working with incredibly simple projects like this I really like to use 3 different byte values, or an array or bytes [R,G,B] rather than shifted concatenated long variables -- if someone doesn't grasp binary math they have a real tough time with that one!

Good fix though!
The error is telling you that the places where you have setColor(); in the code have not been defined. The IDE doesn't know if that is suppose to be a variable, a function, or whatever its suppose to be. You have a function defined for beep(); your just missing your setColor(); function.