Understanding some arduino code

camochase

Well-Known Member
OP
Member
Joined
Oct 26, 2010
Messages
164
Trophies
0
Age
26
XP
294
Country
United States
So im looking at some code that takes the data of a snes controller and displays what is being pressed in the debug. I have never used arduino so im just trying to understand it it says
Code:
if (ControllerData & SNES_B) {
Serial.print(" B");
}
what exactly does the & symbol do in the condition?
 

ResleyZ

Swiggity swaggity swooty, I love my own booty
Member
Joined
Oct 11, 2013
Messages
528
Trophies
1
Age
29
Location
Silicon Valley
XP
544
Country
Netherlands
It seems that Arduino uses either C+ or C++, in which case the & symbol shows where the address will be taken from. In this case it takes the ControllerData from SNES_B. It might be useful to read a little introduction to C++, since it is always helpful to understand the basics. Not sure though, so I may be wrong :P
 

Foxi4

Endless Trash
Global Moderator
Joined
Sep 13, 2009
Messages
30,847
Trophies
3
Location
Gaming Grotto
XP
29,931
Country
Poland
  • Like
Reactions: PityOnU

camochase

Well-Known Member
OP
Member
Joined
Oct 26, 2010
Messages
164
Trophies
0
Age
26
XP
294
Country
United States
I do understand C but the problem was i couldnt see how it was a condition that would work with an if statement but foxi4's comment on how it helps distinguish between buttons helped alot and sorry for not posting what controller data and things are
 

Foxi4

Endless Trash
Global Moderator
Joined
Sep 13, 2009
Messages
30,847
Trophies
3
Location
Gaming Grotto
XP
29,931
Country
Poland
understand C but the problem was i couldnt see how it was a condition that would work with an if statement but foxi4's comment on how it helps distinguish between buttons helped alot and sorry for not posting what controller data and things are

If you don't have a comparison operator in an if statement, the the compiler assumes that you mean if(statement is true?). :)
 

PityOnU

Well-Known Member
Member
Joined
Jul 5, 2012
Messages
1,184
Trophies
1
XP
1,619
Country
United States
It seems that Arduino uses either C+ or C++, in which case the & symbol shows where the address will be taken from. In this case it takes the ControllerData from SNES_B. It might be useful to read a little introduction to C++, since it is always helpful to understand the basics. Not sure though, so I may be wrong :P

Arduino code is closer to Java, so... not even close.

Snaps for Foxi.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • K3Nv2 @ K3Nv2:
    You're as loved as much as Juan now enjoy it
    +1
  • K3Nv2 @ K3Nv2:
    I'm sorry for the insult
  • BakerMan @ BakerMan:
    the difference is i like wario and samus and he likes muscle mommies and feet
    +1
  • BakerMan @ BakerMan:
    wait, i forgot wizards too
  • BigOnYa @ BigOnYa:
    I have a buddy that has a moonshine still and he makes his own shine. He brought me a jar of some peach shine/brandy, shit is damn good. Gonna have to see if can get more.
    +1
  • BakerMan @ BakerMan:
    careful that shit don't make you go blind
  • BigOnYa @ BigOnYa:
    Nuh that's only if you drink what first comes out when distilling, you must throw out the first part of it when it starts running. (Its called the "head(s)" of the run) Or use it for fuel or a general purpose cleaner
    +1
  • K3Nv2 @ K3Nv2:
    If alcohol would've made @BigOnYa blind by now it would have
    +2
  • BigOnYa @ BigOnYa:
    So True.
    +1
  • K3Nv2 @ K3Nv2:
    I should make a poll for bigonya to change his username to DrunkOnYa
    +1
  • BigOnYa @ BigOnYa:
    That's my alt
    +1
  • K3Nv2 @ K3Nv2:
    I don't wanna go to the store someone go for me
  • BigOnYa @ BigOnYa:
    Call my wifey, tell her pick up stuff on her way over.
  • K3Nv2 @ K3Nv2:
    Pick up my door dash meat me in the allyway
    +1
  • BigOnYa @ BigOnYa:
    Wifey is busy, so ill send my buddy @AncientBoi , in his gimp outfit. "who ordered the 6" sausage?""
  • K3Nv2 @ K3Nv2:
    Like subway it's false advertising
    +1
  • BigOnYa @ BigOnYa:
    Ok "who ordered the Vienna sausage?"
  • K3Nv2 @ K3Nv2:
    Uremum
    +1
  • BigOnYa @ BigOnYa:
    My buddy convince me to download and play poker game with him yesterday, called Four Kings Casino, its pretty fun actually, you create a avatar and walk around in a virtual casino, and play any table, or slots with others online.There's even a dance club and bowling alley.
  • SylverReZ @ SylverReZ:
    They should bring advertisements like this back LOL.
  • BakerMan @ BakerMan:
    or that german ninja turtle commercial
    +1
  • K3Nv2 @ K3Nv2:
    Forgot to buy BBQ sauce at the store so made my own ffs
  • RedColoredStars @ RedColoredStars:
    Blues Hog BBQ sauces are pretty good.
  • K3Nv2 @ K3Nv2:
    My insurance has a thing where if I do a virtual visit they'll just send me a $100 gift card to Walmart I'm about to sell a company my medical history for $100 lol
    K3Nv2 @ K3Nv2: My insurance has a thing where if I do a virtual visit they'll just send me a $100 gift card to...