473,508 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Activate User Name

1 New Member
I wish to use the attached code to run my robot as an Obstacle Avoider. a run check on the code stops at CODEavgDistance=0/CODE and I am unable to find the solution.
This is on an Raspberry Pi 3 B with latest Rasbian O/S.
CODEprint ("right")
stop()
count=0
while True:
i=0
avgDistance=0
for i in range(5):
GPIO.output(TRIG, False) #Set TRIG as LOW
time.sleep(0.1) #Delay
GPIO.output(TRIG, True) #Set TRIG as HIGH
time.sleep(0.00001) #Delay of 0.00001 seconds
GPIO.output(TRIG, False) #Set TRIG as LOW
while GPIO.input(ECHO)==0: #Check whether the ECHO is LOW
pulse_start = time.time()
while GPIO.input(ECHO)==1: #Check whether the ECHO is HIGH
pulse_end = time.time()
pulse_duration = pulse_end - pulse_start #time to get back the pulse to sensor
distance = pulse_duration * 17150 #Multiply pulse duration by 17150 (34300/2) to get distance
distance = round(distance,2) #Round to two decimal points
avgDistance=avgDistance+distance
avgDistance=avgDistance/5
print ("avgDistance")
flag=0
if avgDistance < 15: #Check whether the distance is within 15 cm range
count=count+1
stop()
time.sleep(1)
back()
time.sleep(1.5)
if (count%3 ==1) & (flag==0):
right()
flag=1
else:
left()
flag=0
time.sleep(1.5)
stop()
time.sleep(1)
forward()
flag=0/CODE
Oct 29 '21 #1
0 7566

Sign in to post your reply or Sign up for a free account.

Similar topics

8
2504
by: mickeyg | last post by:
i am going through the process of password protecting a directory using ..htaccess and .htpasswd Is there a function to get the user name? Thanks
2
2110
by: John | last post by:
Hi, I have a data driven application which has some generalized components. So, for reuse, I am building the components so they can be reused in other projects ... it takes almost no extra...
3
8787
by: Kanth | last post by:
Hi All, I am developing an .net application (intranet). In the Home page, I would like to show user name (a welcome message) and I don't know how to get the user name through NT user ID. Will...
4
5961
by: Nick | last post by:
I'm developing an intranet app, and want to get the current user name for logging purposes. I've turned off anonymous access, and turned on windows authentication in the IIS config. The apps...
15
2897
by: Tom Nowak | last post by:
I am writing a webapp in which a user is required to enter a login id and password on a login form. I have forms authenticaion coded in my web.config. Once the user is logged in, I want to use the...
6
1599
by: Jozef | last post by:
Hello, I've set up VS2003 on my laptop which is running Win XP pro in a stand alone situation, no domain or dc. When I try and "Create a blank solution", I use the Laptop IP address since...
4
1777
by: jonny | last post by:
I would like to add a password and user name to my website. If the username and password is correct than activate the hyperlinks and buttons. Could you please share some code how how to achieve...
3
2383
by: swetha123 | last post by:
hello, I don't know how to use cookies please help me in this I am using the dream weaver cs4 I designed the navigation bar to my page using dream weaver cs4 navigation bar contains...
2
3566
by: kasun chamara | last post by:
Hi all, i am writing a program in vb6. i need to change the login user name and the password. I did it. but the problem is when i run the program again the changes are not saved. the code is as...
4
5810
by: cariboybgi | last post by:
Good day I created a database in Access 2010 and now after opening it in Office 365 i found some of the functions previously done not working properly. I would be happy if I can get some help...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7124
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1558
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.