-
smiddleton
That’s good to know it’s feasible. Is there a way to do in Pythonista? Or is it going to need Objc? Within a few inches is fine for accuracy.
-
smiddleton
Hey guys,
I’m not sure where to start with this, but here is the idea:
I want to use the microphone and speakers on the iPhone to measure distance. The speakers send out a pulse, the microphone pics up the pulse, and tells you the output in feet or inches or something.The math is the easy part I think. What I can’t seem to find is where to start. Is there an API for the microphone and speakers? Any help is appreciated, thanks!
SM -
-
smiddleton
Thanks Jon B. I appreciate your answers. I found something called nanpy on github. I can't seem to load the module on pythonista on my iPhone. But could that work for loading programming arduino sketches direct from my iPhone?
-
smiddleton
Thanks for the link. I was thinking since I can send commands through pythonista via Bluetooth, why not the actual arduino sketch?
-
-
smiddleton
This is the entire code. Thanks for the help.
import cb import ui class MyCentralManagerDelegateView (ui.View): def __init__(self): self.peripheral = None self.charactetistic= None self.b=ui.Button(title='button') self.add_subview(self.b) self.b.action=self.a self.frame=(0,0,320,570) def did_discover_peripheral(self, p): if p.name == 'Bluno' and not self.peripheral: print ('Discovered ')+ p.name self.peripheral = p cb.connect_peripheral(self.peripheral) def did_connect_peripheral(self, p): print ('Connected Peripheral ') + p.name print ('Looking for Service FFE0') p.discover_services() def did_discover_services(self, p, error): for s in p.services: if s.uuid == 'DFB0': print ('Found Service ') + s.uuid print ('Looking for Characteristic FFE1') p.discover_characteristics(s) def did_discover_characteristics(self, s, error): for c in s.characteristics: if c.uuid == 'DFB1': print ('Found Characteristic') + c.uuid self.characteristic=c print ('Writing H') def a(self,sender): c=self.characteristic self.peripheral.write_characteristic_value(c, 'H', False) def close(self): cb.reset() v=MyCentralManagerDelegateView() cb.set_central_delegate( v) print ('Looking for HM-10-BLE module') cb.scan_for_peripherals() v.present('sheet')```
-
smiddleton
Hey guys,
New question, is there a way to write an arduino sketch, and then upload an arduino sketch with pythonista serial? Or do I need to write the code in pythonista, and flash the arduino firmware to be compatible with pythonista? Thanks in advance for the help.
Steve -
smiddleton
Hmm...I checked and it does say that. What isn't working?
-
smiddleton
Hi, sorry about that. Here is a screen shot. Not a lot of time to post code with my kiddos running around so I grab a few minutes here and there when I can.
Print trace back line 38.
def a(self,sender): c=self.characteristic ``` Error says, Traceback (most recent call last): File "/private/var/mobile/Containers/Shared/AppGroup/DEE1AA35-7934-4C6D-85F7-C62F8C4760BD/Pythonista3/Documents/ui test.py", line 38, in a c=self.characteristic AttributeError: 'MyCentralManagerDelegateView' object has no attribute 'characteristic' Traceback (most recent call last): File "/private/var/mobile/Containers/Shared/AppGroup/DEE1AA35-7934-4C6D-85F7-C62F8C4760BD/Pythonista3/Documents/ui test.py", line 38, in a c=self.characteristic AttributeError: 'MyCentralManagerDelegateView' object has no attribute 'characteristic'