Arduino Part 2 Topics Programming Constructs loops conditionals

  • Slides: 8
Download presentation
Arduino Part 2 Topics: Programming Constructs: loops & conditionals Digital Input

Arduino Part 2 Topics: Programming Constructs: loops & conditionals Digital Input

Trying Something New • Scratch is a project of the Lifelong Kindergarten Group at

Trying Something New • Scratch is a project of the Lifelong Kindergarten Group at the MITMedia Lab. • S 4 A is a Scratch modification that allows for simple programming of the Arduino

Installing and Running S 4 A (S 4 A is already installed on the

Installing and Running S 4 A (S 4 A is already installed on the lab computers but you must still install the firmware. ) • • Download The S 4 A firmware from here Connect your Arduino board to a USB port in your computer Open the Arduino IDE Open the firmware file (S 4 AFirmware 15. ino) in the Arduino IDE In the Tools menu, select the board version and the serial port Load the firmware into your board using Tools > Upload Open the S 4 A program

Try It out

Try It out

Conditional Statement if (some. Condition) { // do stuff if the condition is true

Conditional Statement if (some. Condition) { // do stuff if the condition is true } else { // do stuff if the condition is false } modelect. wordpress. com

while Loop while(expression){ statement(s); } www. toves. org Example int var = 0; while

while Loop while(expression){ statement(s); } www. toves. org Example int var = 0; while (var < 200) { // do 200 times var = var + 1; }

for loop www. visualcplusdotnet. com martin-thoma. com

for loop www. visualcplusdotnet. com martin-thoma. com

Digital Input (introducing the switch) push-button switch www. ladyada. net/ Create the circuit above

Digital Input (introducing the switch) push-button switch www. ladyada. net/ Create the circuit above and then run File -> Examples -> Digital -> Button