tag:blogger.com,1999:blog-87198825161347096112024-03-05T06:18:19.370-08:00Roby the RobotUnknownnoreply@blogger.comBlogger5125tag:blogger.com,1999:blog-8719882516134709611.post-56893340258626000342017-03-26T14:54:00.000-07:002017-03-26T14:54:00.974-07:00Wiring diagram<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP6WDhV3G2Jj5OIsg8F3rNMS0QOBO3ZOsKzYUgLtTlLr5WYaZ_brqgqT6fRhYFJTgct-LvUkxWPd74iucguS4HMXfuw1RMatTjRzwhmIf64hxWiNkTxu-ZDUN1pnJ0th1TNNj6gFnecUo/s1600/Roby+Drawing.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="534" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP6WDhV3G2Jj5OIsg8F3rNMS0QOBO3ZOsKzYUgLtTlLr5WYaZ_brqgqT6fRhYFJTgct-LvUkxWPd74iucguS4HMXfuw1RMatTjRzwhmIf64hxWiNkTxu-ZDUN1pnJ0th1TNNj6gFnecUo/s640/Roby+Drawing.jpg" width="640" /></a></div>
<br /></div>
Robyhttp://www.blogger.com/profile/05563294930477476966noreply@blogger.comtag:blogger.com,1999:blog-8719882516134709611.post-76856081609430982272017-03-26T14:53:00.001-07:002017-03-26T14:53:16.147-07:00Line following example<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoListParagraphCxSpFirst">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">// These constants won't
change. They're used to give names<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">// to the pins used:<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">const int analogInPinL =
A0; // Analog input pin that the IR
sensor is attached to<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">const int analogInPinR =
A1; // Analog input pin that the IR
sensor is attached to<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">const int maxSpeed =
250; // fastest the robot will go (on
one wheel)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int leftBalance = 50;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorLeftSpeed = 150;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorRightSpeed = 150;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int sensorValueL = 0; // value read from the pot<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int outputValueL = 0; // value output to the PWM (analog out)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int sensorValueR = 0; // value read from the pot<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int outputValueR = 0; // value output to the PWM (analog out)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int combinedSensor = 0; // value of both sensors <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">// connect motor controller
pins to Arduino digital pins<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">// motor one<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorSpeedA = 10;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorDirectionAin1 = 9;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorDirectionAin2 = 8;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">// motor two<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorSpeedB = 5;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorDirectionBin3 = 7;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorDirectionBin4 = 6;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">void setup() {<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> // initialize serial communications at 9600
bps:<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> Serial.begin(9600);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> // set all the motor control pins to outputs<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> pinMode(motorSpeedA, OUTPUT);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> pinMode(motorSpeedB, OUTPUT);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> pinMode(motorDirectionAin1, OUTPUT);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> pinMode(motorDirectionAin2, OUTPUT);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> pinMode(motorDirectionBin3, OUTPUT);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> pinMode(motorDirectionBin4, OUTPUT);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">}<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">void loop() {<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> delay(2);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> sensorValueL = analogRead(analogInPinL);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> sensorValueR = analogRead(analogInPinR);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> combinedSensor = sensorValueL + sensorValueR;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> Serial.print("total sensor = ");<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> Serial.println(combinedSensor);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> if (combinedSensor < 2000)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> {<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> // turn on motors<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin1, HIGH);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin2, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin3, HIGH);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin4, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="text-indent: .5in;">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">Serial.println("motor on");<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> motorLeftSpeed = 150;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> motorRightSpeed = 150;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> analogWrite(motorSpeedA, motorLeftSpeed);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> analogWrite(motorSpeedB, motorRightSpeed);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> }<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin1, HIGH);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin2, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin3, HIGH);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin4, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> while (combinedSensor < 1500)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> { <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> if (combinedSensor < 250) <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> {<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> motorLeftSpeed = 150;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> motorRightSpeed = 150;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin1, HIGH);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin2, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin3, HIGH);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin4, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> }<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> if ((sensorValueL > 100) &&
(motorRightSpeed < 250))<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> {<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> motorLeftSpeed = motorLeftSpeed - 15;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> motorRightSpeed = motorRightSpeed + 10;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin1, LOW);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin2,
HIGH); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin3, HIGH);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin4, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> } <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> if ((sensorValueR > 100) &&
(motorLeftSpeed < 250))<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> {<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> motorLeftSpeed = motorLeftSpeed + 10;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> motorRightSpeed = motorRightSpeed - 15;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin1, HIGH);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin2, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin3, LOW);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin4,
HIGH); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> } <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> analogWrite(motorSpeedA, motorLeftSpeed);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> analogWrite(motorSpeedB, motorRightSpeed);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> delay(5);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> // read the analog in value:<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> sensorValueL = analogRead(analogInPinL);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> sensorValueR = analogRead(analogInPinR);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> combinedSensor = sensorValueL +
sensorValueR;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> } <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> // now turn off motors<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin1, LOW);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin2, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin3, LOW);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin4, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> <o:p></o:p></span></div>
<br />
<div class="MsoListParagraphCxSpLast">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">}<o:p></o:p></span></div>
</div>
Robyhttp://www.blogger.com/profile/05563294930477476966noreply@blogger.comtag:blogger.com,1999:blog-8719882516134709611.post-37658690060774021592017-03-26T14:52:00.004-07:002017-03-26T14:52:54.826-07:00Motor test<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoListParagraphCxSpFirst">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">// connect motor controller
pins to Arduino digital pins<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">// motor one<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorSpeedA = 10;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorDirectionAin1 = 9;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorDirectionAin2 = 8;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">// motor two<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorSpeedB = 5;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorDirectionBin3 = 7;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">int motorDirectionBin4 = 6;<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">void setup() {<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> // set all the motor control pins to outputs<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> pinMode(motorSpeedA, OUTPUT);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> pinMode(motorSpeedB, OUTPUT);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> pinMode(motorDirectionAin1, OUTPUT);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> pinMode(motorDirectionAin2, OUTPUT);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> pinMode(motorDirectionBin3, OUTPUT);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> pinMode(motorDirectionBin4, OUTPUT);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">}<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">void loop() {<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin1, HIGH);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin2, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin3, HIGH);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin4, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> analogWrite(motorSpeedA, 250);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> analogWrite(motorSpeedB, 250);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> delay(1000);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> // now turn off motors<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin1, LOW);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionAin2, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin3, LOW);<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> digitalWrite(motorDirectionBin4, LOW); <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;"> <o:p></o:p></span></div>
<div class="MsoNormal">
</div>
<div class="MsoListParagraphCxSpLast">
<span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 107%; mso-bidi-font-size: 14.0pt;">}<o:p></o:p></span></div>
</div>
Robyhttp://www.blogger.com/profile/05563294930477476966noreply@blogger.comtag:blogger.com,1999:blog-8719882516134709611.post-66790498805029403372017-03-26T14:51:00.002-07:002017-03-26T14:51:43.951-07:00Materials<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin-left: .25in;">
</div>
<ol style="text-align: left;">
<li>Robot chassis </li>
<ol>
<li>2 wheels</li>
<li>2 motors</li>
<li>1 bag of wires</li>
<li>1 Connection board</li>
<li>1 On and Off switch</li>
<li>1 Bag of screws</li>
<li>1 battery holder</li>
</ol>
<li>1 Robot Chassis</li>
<li>5 AA batteries</li>
<li>1 L298N Motor control board</li>
<li>2 infrared sensors</li>
<li>1 Arduino board with USB cable</li>
<li>1 power plug</li>
<li>Assorted wires</li>
</ol>
</div>
Robyhttp://www.blogger.com/profile/05563294930477476966noreply@blogger.comtag:blogger.com,1999:blog-8719882516134709611.post-68191374899960902962017-03-26T14:49:00.001-07:002017-03-26T14:49:11.086-07:00Roby the Robot<div dir="ltr" style="text-align: left;" trbidi="on">
<div align="center" class="MsoNormal" style="text-align: center;">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">Introduction<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">I am a 5th grader and won a grant from Disney
(www.ysa.org/grants/youth-grants/disney/) to do a service project about
robotics. My project is about encouraging young kids in the 4th grade to get
excited about science, technology, engineering, and math (STEM) by building a
robot. I am planning to teach a class of kids about basic computer programing
and how to construct a small robot. This is a free experience and we will
provide all the materials, instructions, and volunteers to help everyone. <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">Project
Background<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">I’m doing this project to help kids understand the importance
of robotics. This project is needed so all kids can have a better understanding
of how robotics work. My project is also needed, because when kids start to get
to my age they tend to drift away from S.T.E.M (science, technology,
engineering, and math). However, once you dive in and start learning about
robotics and how to do them you find it might be one of your most favorite
things in the world.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></div>
<div class="MsoNormal">
<span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">This is special to me because I love robotics and I want
other people to see how much fun robotics is. I think that even a kid who has
never tried robotics will instantly fall in love with robotics.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">What You
Will Learn<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">Participants will learn how to build, wire, and program a
small line follower robot. Roby is constructed of a small chassis with 2 motors
controlling the main wheels and a swivel caster. Roby is controlled by a
computer board running a program participants will write. The program uses 2
infrared sensors to detect the line on the ground. When one of the sensors
detects the line the robot turns in that direction so the line stays under the
center of the robot. The robot will keep following the line unless both sensors
touch the black.<o:p></o:p></span></div>
<br /></div>
Robyhttp://www.blogger.com/profile/05563294930477476966noreply@blogger.com