Skip to content

PulseIn function not working with RP2040 #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Abuthala opened this issue Apr 12, 2021 · 2 comments
Closed

PulseIn function not working with RP2040 #187

Abuthala opened this issue Apr 12, 2021 · 2 comments

Comments

@Abuthala
Copy link

Abuthala commented Apr 12, 2021

I downloaded the Arduino ide to use an hc sr04 ultrasonic sensor to measure distance. In the code, I used the pulseIn function to measure the pulse on time of the echo pin. but the function seems to not be defined. The error is sketch\sketch_apr12b.ino.cpp.o: In function `loop': D:\ArduinoCode\sketch_apr12b/sketch_apr12b.ino:28: undefined reference to `pulseIn' collect2.exe: error: ld returned 1 exit status exit status 1 Error compiling for board Raspberry Pi Pico.
The code is as follows:

int trig=15;
int echo=14;
void setup()
{
  pinMode(trig,OUTPUT);
  pinMode(echo,INPUT);
  Serial.begin(9600);
}
void loop()
{
  digitalWrite(trig,LOW);
  delayMicroseconds(2);
  digitalWrite(trig,HIGH);
  delayMicroseconds(10);
  digitalWrite(trig,LOW);
  float duration=pulseIn(echo,HIGH);
  float distance=0.02*duration;
  Serial.println(distance);
  delay(2000);
}
@facchinm
Copy link
Member

Should be fixed by f5ddfa8

@per1234
Copy link
Contributor

per1234 commented Jun 14, 2021

@facchinm can this be closed now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants