Hi I am trying to create a program that when it catches a object that is at the center of the picture that the arduino performs a task.
if (pixy.ccc.blocks[0].m_x - 160 == true )
{
digitalWrite(3, HIGH);
}
else{
digitalWrite(3, LOW);
}
6v6gt
April 22, 2021, 3:27pm
2
There is not enough detail here for anyone to assist you.
I would, however, suggest reducing that code sample to one line
(pixy.ccc.blocks[0].m_x - 160 == true ) ? digitalWrite(3, HIGH) : digitalWrite(3, LOW) ;
or even:
digitalWrite( 3, (pixy.ccc.blocks[0].m_x - 160 == true ) ? HIGH : LOW ) ;
does the same thing.
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
Hi, @trireso
Welcome to the forum.
Please read the post at the start of any forum , entitled "How to use this Forum".
OR
https://forum.arduino.cc/index.php?topic=712198.0
6v6gt:
I would, however, suggest reducing that code sample to one line
(pixy.ccc.blocks[0].m_x - 160 == true ) ? digitalWrite(3, HIGH) : digitalWrite(3, LOW) ;
or even:
digitalWrite( 3, (pixy.ccc.blocks[0].m_x - 160 == true ) ? HIGH : LOW ) ;
does the same thing.
I know it does the same thing,
BUT WHY?
It makes it very hard for us non C++ super experts to read and decipher and even harder for beginners.
Tom...
6v6gt
April 22, 2021, 3:49pm
4
I was simply making some light conversation until the OP showed up with some information that could be used to help solve what ever problem there is. I agree that there are different approaches to the use of C++ short hand constructs but it may indeed even be that the OP is a experienced C++ user.
Actually, that construct could be even shorter with a slight loss of clarity.
system
Closed
August 20, 2021, 3:49pm
5
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.