What am I doing wrong?


i'm building counter uses proximity sensor.  concept have sketch take base reading sensor , compare current reading baseline.  , when significant change increment counter.
my problem counter keeps incrementing tho isn't change?  not sure i'm doing wrong?
code: [select]
int sensorpin = 0;                 // analog pin used connect sharp sensor
int val = 0;                 // variable store values sensor(initially zero)
int count = 0;          //variable store count
int val2 =0;            //variable store current sensor reading
void setup()
{
serial.begin(9600);       // starts serial monitor
val = analogread(sensorpin);    // set base sensorr reading
}

void loop()
{
int val3 = val + 100;
serial.println(val);       //debugging
serial.println(val2);      //debugging
serial.println(val3);      //debugging
delay(10000);              //debugging
val2 = analogread(sensorpin);       // reads value of sharp sensor
if (val2 > val3 );
{
   count = (count++);
   serial.println(count);
}

delay(100);                    // wait time before printing next value
}




code: [select]
if (val2 > val3 );
that's you're doing wrong.
lose semicolon


Arduino Forum > Using Arduino > Programming Questions > What am I doing wrong?


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support