Pages: 1 [2]   Go Down
Author Topic: need some help to writing a code  (Read 944 times)
0 Members and 1 Guest are viewing this topic.
New Jersey
Online Online
Faraday Member
**
Karma: 65
Posts: 3643
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm really not clear from your description what you're trying to do, but looking at the code, it seems that voltage1 controls the forward and back (directions?) and voltage2 does left and right. This line though:
Code:
    else if (voltage2 >= 2.5)  {
Means that you only consider left and right if the forward and back conditions aren't met. Is that what you wanted?
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

YES...
i did some conditions like 
Code:
   if (voltage1 >= 2.5 && voltage2 <=2)  {
...but it is not working good ...so im trying to write the code in another way
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 109
Posts: 4092
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You start a series if if/else statements checking voltage1 the, in the same if/else start testing voltage2 so if any of the voltage1 conditions are true the test of voltage2 will not happen.  Split the voltage checks into 2 blocks of if/else.  Test voltage1 and take action then in a separate if/else test voltage2 and take action.

Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Full Member
***
Karma: 0
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

good idea UKHeliBob ... i will try to split them and check ... i hope this solve my problem ...i appreciate your help..thnx
Logged

Pages: 1 [2]   Go Up
Jump to: