Open Githubmoses opened 6 years ago
Subsequently attempting without the assignment:
Smarthub.turn_motor(80) Traceback (most recent call last): File "
", line 1, in TypeError: unbound method turn_motor() must be called with Smarthub instance as first argument (got int instance instead)
We don't understand how to fix it and please forgive our learning curve and ignorance if this problem is obvious.
First of all, sorry for not responding in any timely manner, I haven't been checking in on this repository for quite a while. Concerning the error you got, the line IndexError: list index out of range
would lead me to believe that during the initialization of the hub, while executing hub = Smarthub()
, the Smarthub was not detected by the Bluetooth adapter.
Assuming that the Bluetooth LE is working properly for the Raspberry PI, I think that the error appeared because the Smarthub wasn't "active" i.e. ready for connections. Make sure that you click the green button on top of the Smarthub beforehand and run the python script while the LED light on the Smarthub is blinking, indicating that it's ready for connections. You also said that you were already able to connect the Raspberry PI to the Smarthub, so I'm guessing that this is why the error appeared.
Regarding the second error, you can't really call out the methods in Smarthub class without first creating an instance of the class. For example, hub = Smarthub()
creates an instance of the class Smarthub (also while doing so, it creates a connection between the Smarthub and your device), and saves it into a variable called "hub". All the methods in Smarthub class are instance methods, meaning they can only be called with an instance. So instead of Smarthub.turn_motor(80)
, you could use hub = Smarthub()
and hub.turn_motor(80)
.
First off let me say WOW. Thank you. I am a newbie and attempting to help my daughter connect her wedo2 to her raspberry pi. We are learning python together. We installed your SDK, and were successful at connection the hub to the pi. However, we get this error message and can't figure out what it means. Anybody's thoughts, comments or help would be greatly appreciated.