0% found this document useful (0 votes)
120 views5 pages

Robotics Reviewer

The document provides an overview of the Arduino IDE (Integrated Development Environment) used for writing code and uploading it to Arduino boards. It describes the main parts of the IDE interface including open, new, upload, and verify. It also notes that code is written mainly in C++ and uses custom Arduino libraries. Additional sections explain sample blink and sensor reading codes to demonstrate basic Arduino functions and programming.

Uploaded by

Pew Face
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views5 pages

Robotics Reviewer

The document provides an overview of the Arduino IDE (Integrated Development Environment) used for writing code and uploading it to Arduino boards. It describes the main parts of the IDE interface including open, new, upload, and verify. It also notes that code is written mainly in C++ and uses custom Arduino libraries. Additional sections explain sample blink and sensor reading codes to demonstrate basic Arduino functions and programming.

Uploaded by

Pew Face
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Robotics Reviewer

Brief Introduction to Arduino:

The Arduino Software (IDE) allows you to write programs and upload them to your
board.

Parts of the Arduino IDE:

 Open – allows you to open an existing sketch


 New – allow you to create a new sketch
 Upload – allows you to compile and upload to code to the board
 Verify – allows you to compile the code

*Code in the Arduino IDE is written manily with C++ along with custom libraries for the
various functions for the Arduino.

Additional Functions of the IDE:


Codes: Explanation:

//blink sketch – turns an led on and off Variable name “led” is initialized to the
value 13, everytime “led” is called in the sketch it
int led{13}; //sets the variable name led to 13 is read as the value it was initialized to; in this case
13.

Using the pinMode(pinNumber, State)


void setup() {
function using led as the indicator for the
pinMode(led, OUTPUT); //sets pin 13 as OUTPUT pinNumber and OUTPUT to initialize pin 13 as an
output pin.
}
Using the digitalWrite(pinNumber, State)
function the state of pin 13 is change from High to
void loop() { low.

digitalWrite(led, HIGH); //sets pin to HIGH state Common misconception:

delay(1000); The delay(time) function does not execute


the digitalWrite() function rather once
digitalWrite(led, LOW); //sets pin to LOW state digitalWrite is called it instead performs the delay
function for the allotted time specified in the
delay(1000);
sketch in this case 1000 milliseconds o 1 second.
}

Explanation:
// Reading Sensor Values Pin A0 is initialized as an input pin. Note:
any pin can be used for analog input not just the
int input_pin{A0};
analog pins, digital pins e.g. pin 1, pin 2, pin 3, pin
void setup() { 4, … can be used as analog pins as well and vice
versa.
pinMode(input_pin, INPUT);
When reading sensor values two functions can be
} used analogRead(pinNumber) and
digitalRead(pinNumber). With analogRead() the
pin number to be read from is declared and a value
void loop() { from 0 -1023 will be returned
analogRead(input_pin); When reading sensor values using digitalRead()
the pin number to be read from is declared and the
digitalRead(input_pin);
pin will be read if it is in HIGH or LOW state
}
// UltraSonic Sensor – simplified | cm reading Explanation:

Medyo mahaba ng onti yung explanation


tas may onting maths tas tinatamad ako mag type
int trigger_pin{13};
so… kabisduhin nyo nalang yung
int echo_pin{12}; get_obejct_distance na function 

void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}

void loop() {
int distance{get_object_distance()};

Serial.println(distance);
delay(250);
}

void get_object_distance() {
int duration{};
double distance{};

digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration / 2) / 29.1;

return distance;
}

You might also like