Digital Output : Getting Started

Digital Output : Getting Started

Let’s Get Started..

Blinky is the “Hello World” of Physical Computing

How do we implement this?

Digital Output

Three functions to know…

C++

Blocks

C++

Blocks

pinMode(pin, INPUT/OUTPUT); ex: pinMode(13, OUTPUT); // NOTE: -> functions are CASE-sensitive digitalWrite(pin, HIGH/LOW); ex: digitalWrite(13, HIGH);

 

image2020-1-21_18-41-57.png

Note: The block above corresponds to digitalWrite(pin, HIGH); inserted into loop().

pinMode(pin, OUTPUT); will be inserted into setup() automatically.

 

C++

Blocks

C++

Blocks

delay(time_ms); ex: delay(2500); // delay of 2.5 sec.

 

image2020-1-21_18-45-15.png

 

https://www.arduino.cc/en/Reference

 

image2019-7-31_17-0-47.png

 

 

image2020-1-19_22-52-35.png

 

 

image2019-7-31_17-0-47.png

 

 

image2020-1-19_22-52-35.png

 

Type (instead of copy-pasting, if you are new to C/C++) this code, click “Upload” and observe the built-in LED. You have just completed your first Arduino program!

C++

Blocks

C++

Blocks

// the setup function runs once when you press reset or power the board void setup() { // initialize digital pin 13 as an output. pinMode(13, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }

 

image2020-1-19_22-34-39.png

Instead of using

image2020-1-19_22-36-18.png

it is fine to use

image2020-1-19_22-33-59.png

for pin 13.