Changes

no edit summary
Line 92: Line 92:  
|Pauses the program for the amount of time specified in the parameter.
 
|Pauses the program for the amount of time specified in the parameter.
 
|}
 
|}
 +
 +
=== Initializing a Pin as an Input or Output ===
 +
When using components you will often have to initialize the pin they are connected to as either an input or output! The syntax for this will vary depending on the component and what pin type it is connected to.
 +
 +
==== Analog Input/Output ====
 +
When trying to manipulate data from an analog pin, the following lines of code are used to read data from it:
 +
int ''variable'' = analogRead(''insert pin number''); //here a variable is being defined to hold the value read from the pin
 +
When you want to write data to the pin the following syntax is used:
 +
int ''variable'' = analogWrite(''insert pin number''); //here a variable is being defined to hold the value read from the pin
 +
 +
==== Digital Input/Output ====
 +
When wanting to use a digital pin you will need to declare as either an input or output in the Void Setup () as follows:
 +
pinMode(LED1, OUTPUT); //For example if you had a pin called LED1
 +
When wanting to write a value to LED1 then you would use the following syntax:
 +
digitalWrite(LED1, HIGH); //Here HIGH or LOW would indicate if you would like the led to turn on - for turning it on you set HIGH, and LOW otherwise.
    
=== Serial Monitors ===
 
=== Serial Monitors ===
MakerRepo Staff, MakerRepo Volunteers
240

edits