Forum.

 

Need help or have a question? Join the conversation in our community topics and share your ideas, tips, or challenges—we’d love to hear from you! Before posting, be sure to check our

 

?

Ultrasonic Sensor n...
 
Notifications
Clear all

Ultrasonic Sensor not working?

5 Posts
2 Users
2 Reactions
6,215 Views
AgentKnopf
(@agentknopf)
Eminent Member
Joined: 3 years ago
Posts: 27
Topic starter  

Hello everyone,

I wonder if there is something wrong with my Otto or if i potentially made a mistaken during assembly. Here are the reproduction steps:

  1. Open editor: https://hprobots.com/otto-code/webcode/webcode.html (blocks)
  2. Load the program i attached (it basically is a forever loop that goes with if/else through the ultrasonic sensor values and changes color/sound based on it - maybe i got a logical error or I am using it incorrectly?)
  3. Execute the program
  4. Expected: When move my hand closer to Otto's ultrasonic sensor (the "eyes") I would expect based on my code that the colors change and the sound changes as well, the closer i get. 
  5. Actual: It stays on the <= 5 cm shows, no matter how far away or close i move my hand, which makes me think I might have made a mistake during assembly 🤔 ?

Looking forward to whether you have any ideas, in the meantime i will double check the assembly of the Otto :) thanks!



   
Camilo reacted
Quote
Topic Tags
AgentKnopf
(@agentknopf)
Eminent Member
Joined: 3 years ago
Posts: 27
Topic starter  

It seems i am unable to attach am otto- file. I selected a file called ultrasonic_color.otto but it's not being uploaded. So I will post an image - it should convey the general idea of the program.



   
Camilo reacted
ReplyQuote
AgentKnopf
(@agentknopf)
Eminent Member
Joined: 3 years ago
Posts: 27
Topic starter  

Ok so i confirmed that the sensor itself works - it correctly detects the distance with the sample project and prints it to the console - so the problem must somehow be in my code - that I should be able to figure out :) case closed.

 



   
ReplyQuote
AgentKnopf
(@agentknopf)
Eminent Member
Joined: 3 years ago
Posts: 27
Topic starter  

For future reference the following works - so the issue was indeed with my code. I really recommend the serial monitor print to debug behaviour - lesson learned :) 



   
ReplyQuote
Camilo
(@cparrapa)
Developer Admin
Joined: 3 years ago
Posts: 112
 

Hi @agentknopf welcome to the community good to see you here!

We coincidentally in the new update are working on a way to show where the error is in the monitor. With ultrasonic we are having this odd behavior that we are trying to see how to settle from the roots so you do not have to create a variable as you did.

Thanks!



   
ReplyQuote
Scroll to Top
This will be available with the release of this product.