Ultrasonic Code Error?

grovepi
firmware
ultrasonicsensor

#1

I’m getting a weird error when i try to run my code which is to display the ultrasonic sensor range i have it simple
from grovepi import*
print(“testing”)
range=ultrasonicRead(2)
print(range)

i get an error
return (number[1] *256 +number[2])
TypeError: ‘int’ object is not subscriptable

i saw a fourm where someone had the same problem but they just updated the firmware and it worked for them, however it doesn’t work for me. I updated it and it still makes the same error. D; please help! thanks!


#2

Hi @bensonshuang,

We know there are some issues with the GrovePi we need to address, but I’m not entirely sure if this is the case here.

Could you run the troubleshooter for the GrovePi and then post it here?
This is the script you have to run:

Thank you!


#3

I found my mistake. I didn’t reflash the grovepi i only reflashed the raspberry T_T. Thank either way c:


#4

That’s good to know. Let us know if there are any other issues!

Thank you!


#5