LOGIN
John Rodrigues
Product and Experience Designer |Entrepreneur |Founder of D&D SmartLabs| Designwithjohn.com
John Rodrigues
103
Product and Experience Designer |Entrepreneur |Founder of D&D SmartLabs| Designwithjohn.com
· Philadelphia, PA, USA
STATUS

Help me fix it

Not getting the needed output, any help to fix it ?

int irSenRead = 7;
int isObstacle = HIGH;
const int ledPinGREEN = 8;
const int ledPinRED =10;


void setup(){

  pinMode( ledPinGREEN,OUTPUT );
    pinMode( ledPinRED,OUTPUT );
  Serial.begin(9600);
}
void loop(){
    isObstacle = digitalRead(irSenRead);
  Serial.println(digitalRead(irSenRead));
  

if (isObstacle ==HIGH){
  Serial.println("Hi");
  digitalWrite(10, HIGH);
}
else
{
 
  Serial.println(" Bye");
  digitalWrite(8, LOW);
}
delay(1000);
}

Contributions
Robert Lancer

Helped to fix the issue

1 like
Like
Award Contribution
Robert Lancer
57
Chief Technology Officer at Collaborizm
· New York, NY, United States

What’s it outputting now?

And this is probably nothing but in general best to log the assigned value of the function as opposed to calling the function twice

  isObstacle = digitalRead(irSenRead);
  Serial.println(digitalRead(irSenRead));

Should be

isObstacle = digitalRead(irSenRead);
Serial.println(isObstacle);
Contribution

Helped to fix the issue

Like
1 like
Award Contribution
John Rodrigues
103
Product and Experience Designer |Entrepreneur |Founder of D&D SmartLabs| Designwithjohn.com
· Philadelphia, PA, USA

Thank you

Like
Award Contribution
Leave a reply...
DISCOVER
CHAT
HIRE
ACTIVITY
FEED
Chat with us!
Help
Write something before you submit it!
Photo updated
Request Sent!
Updated
Copied to Clipboard