EasyManuals Logo

Arduino uno Manual

Arduino uno
11 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #9 background imageLoading...
Page #9 background image
// Set direction to reverse and accelerate from zero to maximum speed
for (int i = 0; i <= 100; i++)
{
Motor('C', 'R', i);
delay(ACCEL_DELAY);
}
delay (2000);
// Decelerate from maximum speed to zero
for (int i = 100; i >= 0; --i)
{
Motor('C', 'R', i);
delay(ACCEL_DELAY);
}
// Turn off motors
Motor('C', 'F', 0);
delay (3000);
}
/*
* Motor function does all the heavy lifting of controlling the motors
* mot = motor to control either 'A' or 'B'. 'C' controls both motors.
* dir = Direction either 'F'orward or 'R'everse
* speed = Speed. Takes in 1-100 percent and maps to 0-255 for PWM control.
* Mapping ignores speed values that are too low to make the motor turn.
* In this case, anything below 27, but 0 still means 0 to stop the motors.
*/
void Motor(char mot, char dir, int speed)
{
// remap the speed from range 0-100 to 0-255
int newspeed;
if (speed == 0)
newspeed = 0; // Don't remap zero, but remap everything else.
else
newspeed = map(speed, 1, 100, MIN_SPEED, 255);
switch (mot) {
case 'A': // Controlling Motor A
if (dir == 'F') {
digitalWrite(INA, HIGH);
}
else if (dir == 'R') {
digitalWrite(INB, LOW);
}
analogWrite(ENA, newspeed);
break;
case 'B': // Controlling Motor B
if (dir == 'F') {
digitalWrite(INB, HIGH);
}
else if (dir == 'R') {

Other manuals for Arduino uno

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Arduino uno and is the answer not in the manual?

Arduino uno Specifications

General IconGeneral
Form factorArduino
CertificationRoHS, FC, CE
Processor model-
Processor frequency- MHz
Microcontroller modelATmega328
Microcontroller frequency16 MHz
DC input voltage7-12 V
Operating voltage5 V
DC current per I/O pin40 mA
Flash memory0.032 MB
Maximum internal memory- GB
SRAM (Static Random Access Memory)2 KB
EEPROM (Electrically Erasable Programmable Read-Only Memory)1 KB
Wi-FiNo
Number of analog I/O pins6
Number of digital I/O pins14
Weight and Dimensions IconWeight and Dimensions
Board dimensions53.4 x 68.6 mm

Related product manuals