hardmood.info

On this website you will find information on Felix Hardmood Beck's involvement at New York University Abu Dhabi (NYUAD) since 2015.

User Tools

Site Tools


09-16-17

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
09-16-17 [2017/09/16 08:37]
felix_hardmood_beck
09-16-17 [2017/09/16 08:43] (current)
felix_hardmood_beck
Line 85: Line 85:
 We want the LED to blink when the button is pressed, that is, the voltage on the pin is HIGH. We can test this condition with an [[https://​www.arduino.cc/​en/​Reference/​If|if() statement]]. if() check to see if something is true or false. If the condition is met (true) it will execute the code in the curly brackets that follow it. If not, it will ignore that code. We want the LED to blink when the button is pressed, that is, the voltage on the pin is HIGH. We can test this condition with an [[https://​www.arduino.cc/​en/​Reference/​If|if() statement]]. if() check to see if something is true or false. If the condition is met (true) it will execute the code in the curly brackets that follow it. If not, it will ignore that code.
  
-Note that we’re using == in the if() statement. This is very different than a single =. This is one of those lovely aspects of programming that is going to cause you more headaches moving forward. Sorry about that. The == is a comparison. A single = sets a value (which we will address next week).+Note that we’re using == in the if() statement. This is very different than a single =. This is one of those lovely aspects of programming that is going to cause you more headaches moving forward. Sorry about that. The == is a comparison. A single = sets a value.
  
 We can read the code above like this : “Read the value of pin 8, if it is HIGH, blink the LED… “. The [[https://​www.arduino.cc/​en/​Reference/​Else|else]] is an aspect of the if() statement that helps control the flow of your program a bit better. It’s not necessary in this instance, but it’s not the worst thing to include either. All it’s doing here is adding an addendum to the above : “Read the value of pin 8, if it is HIGH, blink the LED. Else, if the value is LOW, don’t turn the LED on at all”. We can read the code above like this : “Read the value of pin 8, if it is HIGH, blink the LED… “. The [[https://​www.arduino.cc/​en/​Reference/​Else|else]] is an aspect of the if() statement that helps control the flow of your program a bit better. It’s not necessary in this instance, but it’s not the worst thing to include either. All it’s doing here is adding an addendum to the above : “Read the value of pin 8, if it is HIGH, blink the LED. Else, if the value is LOW, don’t turn the LED on at all”.
/is/htdocs/wp1061956_LA2T3X3UH9/www/nyuad/teaching/data/pages/09-16-17.txt · Last modified: 2017/09/16 08:43 by felix_hardmood_beck