3

I want to control my ultrasonic sensor on arduino uno board with python, but I get an error that says that async and zerojson files are invalid.

I have tried instaling the following files but the async is not compatible with my version of pycharm and thus the error persists. What can I do?

My code is given below:

import pyfirmata
from pyfirmata import util
from pycom import pulses_get
import time

# code for combining arduino with pycharm:
port = pyfirmata.Arduino('/dev/ttyACM0')
iterator = util.Iterator(port)
iterator.start()
trigpin = 12
echopin = 13
speedOfSound = 776.5
start = 1

while start > 0:
    port.digital[trigpin].write(0)
    time.sleep(.002)
    port.digital[trigpin].write(1)
    time.sleep(1.5e-5)
    port.digital[trigpin].write(0)
    time.sleep(1e-5)
    port.digital[echopin].write(1)
    pingTime = pulses_get()
    pingTime = pingTime / 1000000
    pingTime = pingTime / 3600
    targetDistance1 = speedOfSound * pingTime
    targetDistance2 = targetDistance1 / 2
    targetDistance3 = targetDistance2 * 63360

    print(targetDistance3)
coder
  • 109
  • 1
  • 1
  • 6
  • Have you tried `pip install`ing the libs? – Artur Kasza Feb 21 '20 at 08:09
  • Yes, I have and thank you for your help. But now it shows that an identifier is expected before async. Code is given below(This is not my code, this is the code I got from the pycom package.): from . import async, constants, exceptions, utils – coder Feb 21 '20 at 10:04

0 Answers0