int ledPin = 13;
int val = 0;
void setup(){
Serial.begin(9600);
pinMode(ledPin,OUTPUT);
}
void loop()
{
Serial.print(val);
val = analogRead(0);
val /=4; // converter 0-1023 naar 0-255
if (val < 74 )
{
Serial.println(" Value < 74" ); [color=red]<<<will not work [/color]
digitalWrite(ledPin,LOW);
}
if (val > 74 )
{
Serial.println(" Value > 74" ); [color=red]<<<will not work [/color]
digitalWrite(ledPin,HIGH);
if (val >119 )
{
// Serial.println(" Value < 119" ); [color=red]<<<will not work [/color]
digitalWrite(ledPin,LOW);
}
if (val > 139 )
{
//Serial.println(" Value > 139" ); [color=red]<<<will not work [/color]
digitalWrite(ledPin,HIGH);
}
}
}
but it’s not working correct , and i can’t find the problem.
When i turn the potentiometer from 0 - 74 the LED is off , and will on at 75.
When i turn the potentiometer from 74 - 119 the LED will OFF after reach 119.
When i turn the potentiometer from 119 - 139 , after reach 139 the LED wil ON
This is working well,
But now i will put some text in this sketch , it will show the status at hyperterminal
But unfortunately this won’t work :~
the LED will ON at 75 and will not turn OFF ( when i have insert te text in this sketch ,
I have look for the divide marker >> in the Arduino Cookbook but can’t find no information from this.
either the combination else … if is not explain in the Cookbook ( only if … else )