Arduino Progamming Lab

pdf

School

University of South Florida *

*We aren’t endorsed by this school

Course

3000L

Subject

Mechanical Engineering

Date

Oct 30, 2023

Type

pdf

Pages

2

Uploaded by ColonelDuck3489

Report
1. -Arduino is a microcontroller which allows you to easily control sensors and actuators. -In the Arduino programming environment, programs are called "sketches." An Arduino sketch is a piece of code that is written in the Arduino Integrated Development Environment and is typically used to control an Arduino microcontroller. -The extension for an Arduino program, known as a sketch, is typically ".ino". When you create a new sketch in the Arduino IDE or save an existing one, the IDE will automatically assign the ".ino" extension to the file. 2. -Digital Pins: Purpose: Digital pins can be used for both input and output operations and are primarily designed for working with digital signals. They operate in binary, which means they can be in one of two states: HIGH (5V) or LOW (0V). Usage: Digital pins are often used for tasks that involve binary on/off control. You can use them to turn on or off LEDs, control relays, read buttons, or communicate digitally with other devices using protocols like I2C, SPI, or UART. -Analog Pins: Purpose: Analog pins are primarily used for reading analog signals, which are continuous and can have values within a specific range. These pins are designed to interface with analog sensors and devices. Usage: Analog pins are commonly used for reading data from sensors like light sensors, temperature sensors, potentiometers, and various other sensors that provide data as a voltage level. They are also used for analog-to-digital conversion (ADC) to convert analog voltage levels into digital values that the Arduino can process. 3. Importing libraries in the Arduino IDE is a fundamental part of the platform's ecosystem, enabling you to leverage existing code and build more efficient and feature-rich Arduino projects. 4. The purpose of the push button on the Arduino Uno board is to reset the microcontroller. When pressed, it restarts the program running on the Arduino Uno, effectively restarting the sketch from the beginning. 5. Comments are annotations in code that provide explanations and documentation for human readers. They are necessary to enhance code readability, document the code's functionality, and facilitate collaboration and debugging. 6. Two examples of data types that can be used in Arduino programming are: -int: The "int" data type is used to store integer values. It is commonly used for variables that hold whole numbers. -float: The "float" data type is used to store floating-point numbers, which are numbers with decimal points. It is used for variables that require precision in representing fractional values. 7. A local variable is declared within a specific function or block and can only be accessed and used within that function or block, while a global variable is declared outside of any function and can be accessed and modified by any part of the program.
8. a) void loop() { int motorSpeed = 150; // Speed control (0-255) // Set motor A speed and direction analogWrite(enA, motorSpeed); digitalWrite(in1, HIGH); digitalWrite(in2, LOW); // Set motor B speed and direction (opposite direction) analogWrite(enB, motorSpeed); digitalWrite(in3, LOW); // Reversed direction compared to motor A digitalWrite(in4, HIGH); // Reversed direction compared to motor A } b) void loop() { int motorSpeed = 150; // Speed control for motor A (0-255) int motorSpeed2 = 2 * motorSpeed; // Twice the speed of motor A for motor B // Set motor A speed and direction analogWrite(enA, motorSpeed); digitalWrite(in1, HIGH); digitalWrite(in2, LOW); // Set motor B speed and direction (same direction as motor A) analogWrite(enB, motorSpeed2); // Motor B spins at twice the speed of motor A digitalWrite(in3, HIGH); digitalWrite(in4, LOW); }
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help

Browse Popular Homework Q&A

Q: Calculate the critical angle for light to travel from glass (n = 1.56) to water (n = 1.33).
Q: You get a new credit card and make an initial charge, but then charge nothing else. The table below…
Q: What is the rate of heat transfer between hot oil and outside air?
Q: What are the limitations of interpreting behavior from phenotype?
Q: -8 -2 -9 6 4 4 0 4 w is in Col A. Is w in Nul A? Let A = 8 and w= 27 -2 Determine if
Q: How did the growth of tobacco impact the land, culture, economy, politics, and social relations both…
Q: Which of these two gases has the greater average molecular velocity? Flask A Flask B
Q: onsider the following data: Monthly Profit of an Auto Repair Shop Month Jan-14 Feb-14 Mar-14 Apr-14…
Q: A ball is suspended from a light 1.2 m string as shown. The string makes an angle of 25 degrees with…
Q: A hydroelectric power facility converts the gravitational potential energy of water behind a dam to…
Q: You are reviewing your patient’s orders in the electronic medical record. You have verified the…
Q: We have designed silicon NMOS capacitor. The metal gate has a gate potential M=1eV, the p layer is…
Q: You are a nurse on a busy medical-surgical unit and know you must use your time management skills to…
Q: E. On a survey, why might you want to measure income at the ratio rather than ordinal level? Why…
Q: Vapor pressure curves for diethyl ether [(C₂H5)2 O], ethanol (C₂H5OH), and water. (Select all that…
Q: A block of mass 2.2 kg is sitting on a frictionless ramp with a spring at the bottom that has a…
Q: can you show more work
Q: Pure breeding red fleshed tomatoes crossed with pure breeding yellow fleshed tomatoes produced all…
Q: iM8 n=1 5 nº.9
Q: an LTI system with impulse response
Q: student randomly grabs 2 socks from her drawer, which contains 11 white socks and 8 black socks.…
Q: Data from the Statistical Abstract of the United States show that in 1995 there were 56.61 thousand…