Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>RedBot: RedBotMotor Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">RedBot
</div>
<div id="projectbrief">RedBot Arduino Library for the Sparkfun RedBot</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="classes.html"><span>Class Index</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('class_red_bot_motor.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Variables</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="class_red_bot_motor-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">RedBotMotor Class Reference</div> </div>
</div><!--header-->
<div class="contents">
<p><code>#include <<a class="el" href="_red_bot_8h_source.html">RedBot.h</a>></code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ae2c204ef267fe9bde43cf6caeb693eae"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="class_red_bot_motor.html#ae2c204ef267fe9bde43cf6caeb693eae">RedBotMotor</a> ()</td></tr>
<tr class="separator:ae2c204ef267fe9bde43cf6caeb693eae"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a92a78cd6ecaf47cb50b1c8059375c261"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_red_bot_motor.html#a92a78cd6ecaf47cb50b1c8059375c261">drive</a> (int speed)</td></tr>
<tr class="separator:a92a78cd6ecaf47cb50b1c8059375c261"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aeef7a9abd94a74ea87860163ecad6764"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_red_bot_motor.html#aeef7a9abd94a74ea87860163ecad6764">leftDrive</a> (int speed)</td></tr>
<tr class="separator:aeef7a9abd94a74ea87860163ecad6764"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:acf1246d90ff26ec68748e16e7d80e78b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_red_bot_motor.html#acf1246d90ff26ec68748e16e7d80e78b">rightDrive</a> (int speed)</td></tr>
<tr class="separator:acf1246d90ff26ec68748e16e7d80e78b"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a61a73a2dd543697bc966bbb0de47a81d"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_red_bot_motor.html#a61a73a2dd543697bc966bbb0de47a81d">pivot</a> (int speed)</td></tr>
<tr class="separator:a61a73a2dd543697bc966bbb0de47a81d"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a2e55b7f88c4c081928370fe711ca61ef"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_red_bot_motor.html#a2e55b7f88c4c081928370fe711ca61ef">stop</a> ()</td></tr>
<tr class="separator:a2e55b7f88c4c081928370fe711ca61ef"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ac757e02db079bc5a57774b4c7bbc3737"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_red_bot_motor.html#ac757e02db079bc5a57774b4c7bbc3737">leftStop</a> ()</td></tr>
<tr class="separator:ac757e02db079bc5a57774b4c7bbc3737"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:affb91e6e7205c9df1482bb58f0c0ed05"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_red_bot_motor.html#affb91e6e7205c9df1482bb58f0c0ed05">rightStop</a> ()</td></tr>
<tr class="separator:affb91e6e7205c9df1482bb58f0c0ed05"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a64540ac32e023eff2c93fd60f0537562"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_red_bot_motor.html#a64540ac32e023eff2c93fd60f0537562">brake</a> ()</td></tr>
<tr class="separator:a64540ac32e023eff2c93fd60f0537562"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a1fbd19b1b3ef733664397c183bb910ea"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_red_bot_motor.html#a1fbd19b1b3ef733664397c183bb910ea">leftBrake</a> ()</td></tr>
<tr class="separator:a1fbd19b1b3ef733664397c183bb910ea"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a710584b709cd8a7a7070cbbf3d0a6ed6"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_red_bot_motor.html#a710584b709cd8a7a7070cbbf3d0a6ed6">rightBrake</a> ()</td></tr>
<tr class="separator:a710584b709cd8a7a7070cbbf3d0a6ed6"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>A class for controlling the RedBot's motors. A single object of the <a class="el" href="class_red_bot_motor.html">RedBotMotor</a> class controls both the left and right motors of the RedBot. </p>
</div><h2 class="groupheader">Constructor & Destructor Documentation</h2>
<a class="anchor" id="ae2c204ef267fe9bde43cf6caeb693eae"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">RedBotMotor::RedBotMotor </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Create a new object of the <a class="el" href="class_red_bot_motor.html">RedBotMotor</a> class.</p>
<p>A single <a class="el" href="class_red_bot_motor.html">RedBotMotor</a> instance is used for both motors on the RedBot. </p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a64540ac32e023eff2c93fd60f0537562"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RedBotMotor::brake </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Immediately stop both motors and hold their current positions.</p>
<p>The <a class="el" href="class_red_bot_motor.html#a64540ac32e023eff2c93fd60f0537562">RedBotMotor::brake()</a> method effectively shorts the terminals of the motors and therefore results in the motors stopping much more quickly than the <a class="el" href="class_red_bot_motor.html#a2e55b7f88c4c081928370fe711ca61ef">RedBotMotor::stop()</a> method. After a call to <a class="el" href="class_red_bot_motor.html#a64540ac32e023eff2c93fd60f0537562">RedBotMotor::brake()</a>, the motors will be much harder to turn, which will allow the RedBot to hold its position on a slope.</p>
<p>Usage Example:</p>
<p>#include <<a class="el" href="_red_bot_8h_source.html">RedBot.h</a>></p>
<p><a class="el" href="class_red_bot_motor.html">RedBotMotor</a> motor;</p>
<p>void setup() {</p>
<p>}</p>
<p>void loop() {</p>
<p>// Drive for a bit</p>
<p>for (int x = 0; x < 1000; x++) {</p>
<p>motor.drive (200);</p>
<p>}</p>
<p>// Stop the motors and hold current position</p>
<p>motor.brake();</p>
<p>} </p>
</div>
</div>
<a class="anchor" id="a92a78cd6ecaf47cb50b1c8059375c261"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RedBotMotor::drive </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>speed</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Run both motors at a given speed.</p>
<p>If <em>speed</em> is a positive integer, drives both motors forward, and if <em>speed</em> is a negative integer, drives both motors backward. In either case, the motors are driven at the absolute value at <em>speed</em>. Allowable values for <em>speed</em> are -255 to 255 inclusive, however values in -75 to 0 and 0 to 75 inclusive may not provide enough torque to start the motor turning.</p>
<p>Usage Example:</p>
<p>#include <<a class="el" href="_red_bot_8h_source.html">RedBot.h</a>></p>
<p><a class="el" href="class_red_bot_motor.html">RedBotMotor</a> motor;</p>
<p>void setup() {</p>
<p>}</p>
<p>void loop () {</p>
<p>// Drive forward at a speed of 200</p>
<p>motor.drive (200);</p>
<p>// Drive backward at a speed of 150</p>
<p>motor.drive (-150)</p>
<p>} </p>
</div>
</div>
<a class="anchor" id="a1fbd19b1b3ef733664397c183bb910ea"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RedBotMotor::leftBrake </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Immediately stop the left motor and hold its current position.</p>
<p>The <a class="el" href="class_red_bot_motor.html#a1fbd19b1b3ef733664397c183bb910ea">RedBotMotor::leftBrake()</a> method effectively shorts the terminals of * the left motor and therefore results in the motor stopping much more quickly than the RedBotMotor::leftRtop() method. After a call to <a class="el" href="class_red_bot_motor.html#a1fbd19b1b3ef733664397c183bb910ea">RedBotMotor::leftBrake()</a>, the motor will be much harder to turn, which will allow the RedBot to hold its position on a slope. The right motor will still be able to be driven via <a class="el" href="class_red_bot_motor.html#acf1246d90ff26ec68748e16e7d80e78b">RedBotMotor::rightDrive()</a> method. </p>
</div>
</div>
<a class="anchor" id="aeef7a9abd94a74ea87860163ecad6764"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RedBotMotor::leftDrive </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>speed</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Run the left motor at a given speed.</p>
<p>If <em>speed</em> is a positive integer, drives the motor forward, and if <em>speed</em> is a negative integer, drives motor backward. In either case, the motor is driven at the absolute value at <em>speed</em>. Allowable values for <em>speed</em> are -255 to 255 inclusive, however values in -75 to 0 and 0 to 75 inclusive may not provide enough torque to start the motor turning.</p>
<p>Usage Example:</p>
<p>#include <<a class="el" href="_red_bot_8h_source.html">RedBot.h</a>></p>
<p><a class="el" href="class_red_bot_motor.html">RedBotMotor</a> motor;</p>
<p>void setup() {</p>
<p>}</p>
<p>void loop () {</p>
<p>// Drive the left motor forward at a speed of 200</p>
<p>motor.LeftDrive (200);</p>
<p>// Drive the left motor backward at a speed of 150</p>
<p>motor.leftDrive (-150)</p>
<p>} </p>
</div>
</div>
<a class="anchor" id="ac757e02db079bc5a57774b4c7bbc3737"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RedBotMotor::leftStop </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Discontinue PWM output to the left motor.</p>
<p>This method turns off the left motor by stopping PWM output to the motor. After a call to this method, the left motor will continue to coast for a short time. In order to continue driving just the right motor, use <a class="el" href="class_red_bot_motor.html#acf1246d90ff26ec68748e16e7d80e78b">RedBotMotor::rightDrive(int speed)</a> </p>
</div>
</div>
<a class="anchor" id="a61a73a2dd543697bc966bbb0de47a81d"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RedBotMotor::pivot </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>speed</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Pivot the RedBot to either the left or right.</p>
<p>If <em>speed</em> is a positive integer, the RedBot pivots to the left. If <em>speed</em> is a negative integer, the RedBot pivots to the right. In either case, the motors are driven in their respective directions at the absolute value of <em>speed</em>. When pivoting left, the left motor drives backwards and the right motor drives forward; when pivoting right, the motors drive in the opposite directions. Allowable values for <em>speed</em> are -255 to 255 inclusive, however values in -75 to 0 and 0 to 75 inclusive may not provide enough torque to start the motor turning.</p>
<p>Usage Example:</p>
<p>#include <<a class="el" href="_red_bot_8h_source.html">RedBot.h</a>></p>
<p><a class="el" href="class_red_bot_motor.html">RedBotMotor</a> motor;</p>
<p>void setup() {</p>
<p>}</p>
<p>void loop() {</p>
<p>// Pivot to the left at a speed of 150</p>
<p>motor.pivot (150);</p>
<p>// Pivot to the right at a speed of 75</p>
<p>motor.pivot (-75);</p>
<p>} </p>
</div>
</div>
<a class="anchor" id="a710584b709cd8a7a7070cbbf3d0a6ed6"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RedBotMotor::rightBrake </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Immediately stop the right motor and hold its current position.</p>
<p>The <a class="el" href="class_red_bot_motor.html#a710584b709cd8a7a7070cbbf3d0a6ed6">RedBotMotor::rightBrake()</a> method effectively shorts the terminals of the right motor and therefore results in the motor stopping much more quickly than the RedBotMotor::rightRtop() method. After a call to <a class="el" href="class_red_bot_motor.html#a710584b709cd8a7a7070cbbf3d0a6ed6">RedBotMotor::rightBrake()</a>, the motor will be much harder to turn, which will allow the RedBot to hold its position on a slope. The left motor will still be able to be driven via <a class="el" href="class_red_bot_motor.html#aeef7a9abd94a74ea87860163ecad6764">RedBotMotor::leftDrive()</a> method. </p>
</div>
</div>
<a class="anchor" id="acf1246d90ff26ec68748e16e7d80e78b"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RedBotMotor::rightDrive </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>speed</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Run the right motor at a given speed.</p>
<p>If <em>speed</em> is a positive integer, drives the motor forward, and if <em>speed</em> is a negative integer, drives motor backward. In either case, the motor is driven at the absolute value at <em>speed</em>. Allowable values for <em>speed</em> are -255 to 255 inclusive, however values in -75 to 0 and 0 to 75 inclusive may not provide enough torque to start the motor turning.</p>
<p>Usage Example:</p>
<p>#include <<a class="el" href="_red_bot_8h_source.html">RedBot.h</a>></p>
<p><a class="el" href="class_red_bot_motor.html">RedBotMotor</a> motor;</p>
<p>void setup() {</p>
<p>}</p>
<p>void loop () {</p>
<p>// Drive the right motor forward at a speed of 200</p>
<p>motor.RightDrive (200);</p>
<p>// Drive the right motor backward at a speed of 150</p>
<p>motor.rightDrive (-150)</p>
<p>} </p>
</div>
</div>
<a class="anchor" id="affb91e6e7205c9df1482bb58f0c0ed05"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RedBotMotor::rightStop </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Discontinue PWM output to the right motor.</p>
<p>This method turns off the right motor by stopping PWM output to the motor. After a call to this method, the right motor will continue to coast for a short time. In order to continue driving just the left motor, use <a class="el" href="class_red_bot_motor.html#aeef7a9abd94a74ea87860163ecad6764">RedBotMotor::leftDrive(int speed)</a> </p>
</div>
</div>
<a class="anchor" id="a2e55b7f88c4c081928370fe711ca61ef"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void RedBotMotor::stop </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Discontinue PWM output to both motors.</p>
<p>This method turns off both motors by stopping PWM output to the motors. After a call to this method, the motors will continue to coast for a short time.</p>
<p>Usage Example:</p>
<p>#include <<a class="el" href="_red_bot_8h_source.html">RedBot.h</a>></p>
<p><a class="el" href="class_red_bot_motor.html">RedBotMotor</a> motor;</p>
<p>void setup() {</p>
<p>}</p>
<p>void loop() {</p>
<p>// Drive for a bit</p>
<p>for (int x = 0; x < 1000; x++) {</p>
<p>motor.drive (200);</p>
<p>}</p>
<p>// Stop the motors</p>
<p>motor.stop();</p>
<p>} </p>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>Arduino/RedBot/<a class="el" href="_red_bot_8h_source.html">RedBot.h</a></li>
<li>Arduino/RedBot/RedBotMotor.cpp</li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="class_red_bot_motor.html">RedBotMotor</a></li>
<li class="footer">Generated on Fri Jan 3 2014 23:40:23 for RedBot by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.5 </li>
</ul>
</div>
</body>
</html>
9a9ef921bThis file is pinned to the selected release. Download the original to open it in your design tool.