please help with the program

Hi,
please help with the program.
Despite the condition:
if (outPinB == HIGH); {
digitalWrite (outPinA, LOW);
digitalWrite (outPinC, LOW);
}
output outpinB = 1, outpinA = 1 and outpinC = 1

Despite the condition:
if (outPinA == LOW && outPinC == LOW); {
digitalWrite (outPinB, LOW);
}
output outpinA = 0 and outpinC = 0 and outpinB = 1

Thanks for help

singleended_5.ino (1.64 KB)

Lose the semicolon after the if condition

You are also confusing the pin definitions with the value of the pin
Your code

#include <Wire.h>
#include <Adafruit_ADS1015.h>

Adafruit_ADS1015 ads;     /* Use thi for the 12-bit version */

int outPinA =  3;      //        Vystup  A
int outPinB =  4;      //        Vystup  B
int outPinC =  5;      //        Vystup  C

void setup(void)
{
  Serial.begin(115200);

  ads.setGain(GAIN_TWOTHIRDS);  // 2/3x gain +/- 6.144V  1 bit = 3mV      0.1875mV (default)

  ads.begin();

  pinMode(outPinA, OUTPUT);      // sets the digital pin as output
  pinMode(outPinB, OUTPUT);      // sets the digital pin as output
  pinMode(outPinC, OUTPUT);      // sets the digital pin as output
}

void loop(void)
{
  int16_t adc1 , adc2;                // iniciacia vstupov
  adc1 = ads.readADC_SingleEnded(1);  // definovanie vstup 1
  adc2 = ads.readADC_SingleEnded(2);  // definovanie vstup 2
  int difference = adc1 - adc2 ;      // rozdiel vstupov vypocet

  if (outPinB == HIGH ); {    // ak je OutB 1 tak OutA a Out C je 0
    digitalWrite(outPinA, LOW);
    digitalWrite(outPinC, LOW);
  }

  if (outPinA == LOW && outPinC == LOW); { // ak OutpinA a OutpinC je 0, tak Outpin B je 0
    digitalWrite(outPinB, LOW);
  }

  digitalWrite (outPinB, difference < -100 || difference > 100 ? LOW : HIGH) ; // podnienka vystupu C na vstupoch
  digitalWrite (outPinA, adc1 > 900 ? HIGH : LOW ); // podmienka vystupu A
  digitalWrite (outPinC, adc2 > 900 ? HIGH : LOW ); // podmienka vystupu C


  Serial.print("AIN0: "); Serial.println(adc1);     // vypis vstupu 1
  Serial.print("AIN1: "); Serial.println(adc2);     // vypis vstupu 1
  Serial.print("DIF: "); Serial.println(difference);// vypis rozdielu
  Serial.println(" ");

}

outPinA is the value 3. It is never HIGH/LOW/0/1. You have to do a digitalRead(outPinA) to see the state. It is also odd that you declare these pins as OUTPUT, but then start testing the values. If they are OUTPUTs, the code should be driving them HIGH or LOW.

I will ask the question differently …
I have a function code.
But I need to add output conditions.
Can you help me?

if Out2 == HIGH
so Out1; Out3 == LOW

if Out1; Out3 <400 (if adc1; adc2 <400)
so Out2 == LOW

Thank you very much

Code: [Select]
#include <Wire.h>
#include <Adafruit_ADS1015.h>

Adafruit_ADS1015 ads; /* Use thi for the 12-bit version */

int outPinA = 3; // Vystup A
int outPinB = 4; // Vystup B
int outPinC = 5; // Vystup C

void setup(void)
{
Serial.begin(115200);

ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)

ads.begin();

pinMode(outPinA, OUTPUT);
pinMode(outPinB, OUTPUT);
pinMode(outPinC, OUTPUT);
}

void loop(void)
{
int16_t adc1 , adc2;
adc1 = ads.readADC_SingleEnded(1); // input 1
adc2 = ads.readADC_SingleEnded(2); // input 2

int difference = adc1 - adc2 ;

digitalWrite (outPinB, difference < -100 || difference > 100 ? LOW : HIGH) ; // outputB
digitalWrite (outPinA, adc1 > 900 ? HIGH : LOW ); // outputA
digitalWrite (outPinC, adc2 > 900 ? HIGH : LOW ); // outputC

Serial.print("AIN0: "); Serial.println(adc1); // vypis input 1
Serial.print("AIN1: "); Serial.println(adc2); // vypis input 2
Serial.print("DIF: “); Serial.println(difference);// vypis difference
Serial.println(” ");
delay(10);
}

patrikxxl:
I will ask the question differently ...

To make it easy for people to help you please modify your post and use the code button </>
codeButton.png

so your code 
looks like this

and is easy to copy to a text editor. See How to use the Forum

...R

I will ask the question differently …
I have a function code.
But I need to add output conditions.
Can you help me?

Your code is setting the output conditions, so what’s the problem?

I apologize for the incorrect posting.
And a request in my mother tongue.

The following output parameters I can’t write in my function code:

if … outPinB == HIGH
must be … outPinA and outPinC == LOW

if … outPinA and outPinC <400 (if adc1; adc2 <400)
must be … outPinB == LOW

I’ve found different ways, but I’m still making a mistake somewhere and these conditions don’t work.

Did you try reply #1?

  if (outPinB == HIGH ); {    // ak je OutB 1 tak OutA a Out C je 0
   //remove this ------^

You do it several places and makes your if() statement useless and makes all the code inside {} ALWAYS execute

Thank you for saying “please”.

New people often say: “I want” “I need” .

patrikxxl:
I apologize for the incorrect posting.

Your apology is noted. But it is rather meaningless if you don't fix the problem.

...R

For larryd:
Sorry I didn't mean to be rude. ;D
Google Translator sometimes omits a sentence or word.
And thank you in advance for any help.
For blh64:
I deleted the " ; "
Nevertheless, with the same values for adc1 and adc2 it is outPinB == HIGH.
Even in the case that the two inputs is zero.

Sorry I didn't mean to be rude. ;D

No, you were not rude, you were respectful , or maybe Google Translator was respectful . :wink: