Controls Reviewer 1
Controls Reviewer 1
Controls Reviewer 1
Controls Note
Int = integer (declaration of variable / to limit the input (no decimal just whole number))
Ex. “int redLED = 11;” – means the redLED is a variable that represents no. 11
long = Same concept with integer but has no limitation for the integer, e.g. 696,969,696
Ex. “long duration;” – variable for the duration of the sound wave travel (used in Act 5)
Ex. “float distance;” variable for measured distance (expected output Y.xx, where Y is whole number and
xx is decimal)
Ex. “#define echoPin 10” – echoPin is a variable for 10 Note: doesn’t need to have semicolon
pinMode = used to declare the pin location from 0-13 from Arduino and establishing if its for Input or
Output
Ex. “pinMode(echoPin, Input);” means the echopin which is located in port 10 is expected to be the
Input data from the ultrasonic sensor. (refer to the example above). The proper format for this is
//”pinMode(port no., Input/Output);
Serial.print & Serial.println = the difference of the two is that the Serial.print prints only the number or
string, while Serial.println prints it with a newline character
Ex.
digitalWrite = this determines what port will be turned on or turned off, turn on = HIGH, turn off = LOW
Ex. “digitalWrite(echoPin, LOW);” the format for this statement is “digitalWrite(port no., HIGH/LOW);”
delay(time) = the unit of the delay is in ms or milliseconds, //1000milliseconds = 1second, usually used
before and after the “digitalWrite” command
Serial.available() = usually used for the human input in the Serial Monitor
Serial.parseInt() = usually used after you used the Serial.available, this will print the valid integer
inputed by human in the Serial Monitor
Below are some of my Code;
//From Activity 6 (not yet finished and possibly not working) //activity that combines ultrasonic sensor
and servo motor
#include <Servo.h>
//Code from Sir Doroliat (servo motor only guided by User Input thru Serial Monitor)
#include <Servo.h> }
Serial.begin(6900); myFirstServo.write(servoPos);
myFirstServo.attach(servoPin);
}