Converting analog to digital

Search for ternary operator. See e.g. Ternary conditional operator - Wikipedia

I'm not sure why you're trying to what you're trying to do. with few exceptions, analog inputs can be used as digital inputs so digitalWrite will work