Difference between revisions of "Sumobotsclass"

From LVL1
Jump to navigation Jump to search
Line 1: Line 1:
 +
 +
== Motor control code ==
 +
 +
<nowiki>
 +
#define motor1dir 8                    //direction motor 2
 +
#define motor1speed 9  //pwm control motor 1
 +
#define motor2dir 11                    //direction motor 2
 +
#define motor2speed 10  //pwm control motor 2
 +
#define ledpin 13
 +
 +
 +
void setup() {
 +
  // put your setup code here, to run once:
 +
  pinMode(motor1dir, OUTPUT);
 +
  pinMode(motor1speed, OUTPUT);
 +
  pinMode(motor2dir, OUTPUT);
 +
  pinMode(motor2speed, OUTPUT);
 +
  pinMode(ledpin, OUTPUT);
 +
  digitalWrite(ledpin, HIGH);
 +
  delay(3000);
 +
  digitalWrite(ledpin, LOW);
 +
}
 +
 +
void loop() {
 +
  // put your main code here, to run repeatedly:
 +
 +
  analogWrite(motor2speed,255);    //go all out
 +
  analogWrite(motor1speed,255);
 +
 +
  digitalWrite(motor1dir, HIGH);    //go this way
 +
  digitalWrite(motor2dir, HIGH);
 +
  delay(3000);
 +
 +
  digitalWrite(motor1dir, LOW);    //go opposite way
 +
  digitalWrite(motor2dir, LOW);
 +
  delay(3000);
 +
 +
  analogWrite(motor1speed,0);      //stop
 +
  analogWrite(motor2speed,0);
 +
  delay(3000);
 +
}
 +
 +
</nowiki>
 +
 +
 +
----
 +
 +
 +
[http://dl.dropbox.com/u/253442/PololuQTRSensorsForArduino.zip QTR line sensors]
 +
 +
 +
 +
----
 +
 +
 +
 
Need a Mechapad or some Protoboard and Patience
 
Need a Mechapad or some Protoboard and Patience
 
{| {{table}}
 
{| {{table}}
Line 5: Line 61:
 
| align="center" style="background:#f0f0f0;"|'''where'''
 
| align="center" style="background:#f0f0f0;"|'''where'''
 
| align="center" style="background:#f0f0f0;"|'''amount per bot'''
 
| align="center" style="background:#f0f0f0;"|'''amount per bot'''
|-
 
| connectors||screw terminal 5mm 2 hole||http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=281-1442-ND||2
 
 
|-
 
|-
 
| motor driver||h-bridge||http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=296-9911-5-ND||1
 
| motor driver||h-bridge||http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=296-9911-5-ND||1
Line 58: Line 112:
  
 
[http://dl.dropbox.com/u/253442/motordriver.zip eagle design files]
 
[http://dl.dropbox.com/u/253442/motordriver.zip eagle design files]
[http://dl.dropbox.com/u/253442/PololuQTRSensorsForArduino.zip QTR line sensors]
 
 
[http://arduino.googlecode.com/files/arduino-0022.zip arduino windows]
 

Revision as of 00:49, 23 October 2011

Motor control code

#define motor1dir 8 //direction motor 2 #define motor1speed 9 //pwm control motor 1 #define motor2dir 11 //direction motor 2 #define motor2speed 10 //pwm control motor 2 #define ledpin 13 void setup() { // put your setup code here, to run once: pinMode(motor1dir, OUTPUT); pinMode(motor1speed, OUTPUT); pinMode(motor2dir, OUTPUT); pinMode(motor2speed, OUTPUT); pinMode(ledpin, OUTPUT); digitalWrite(ledpin, HIGH); delay(3000); digitalWrite(ledpin, LOW); } void loop() { // put your main code here, to run repeatedly: analogWrite(motor2speed,255); //go all out analogWrite(motor1speed,255); digitalWrite(motor1dir, HIGH); //go this way digitalWrite(motor2dir, HIGH); delay(3000); digitalWrite(motor1dir, LOW); //go opposite way digitalWrite(motor2dir, LOW); delay(3000); analogWrite(motor1speed,0); //stop analogWrite(motor2speed,0); delay(3000); }




QTR line sensors




Need a Mechapad or some Protoboard and Patience

what type where amount per bot
motor driver h-bridge http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=296-9911-5-ND 1
transistor NPN Transistor http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=2N3904GOS-ND 2
Capacitor Ceramic 0.1uF http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=399-4266-ND 2
diode Diode Rectifier - 1A 50V http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=641-1311-1-ND 8
Crystal 16MHz Crystal 16MHz http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=887-1019-ND 1
Microcontroller ATMega328 http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=ATMEGA328-PU-ND 1
Resistor 10k Ohm http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=CF14JT10K0CT-ND 5
Resistor 1k ohm http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=CF14JT1K00CT-ND 2
Resistor 220ohm http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=CF14JT220RCT-ND 2
Voltage regulator 7805 http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=LM7805CT-ND 1
Capacitor Electrolytic 10uF/25V http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=P975-ND 1
Power switch switch http://search.digikey.com/scripts/dksearch/dksus.dll?pname&WT.z_cid=&name=679-1854-ND 1
reset button button http://search.digikey.com/scripts/dksearch/dksus.dll?pname&WT.z_cid=&name=SW400-ND 1
Capacitor Electrolytic 100uF/25V http://search.digikey.com/scripts/dksearch/dksus.dll?vendor=0&keywords=P10269-ND 1
Motors/wheels GM8 http://www.solarbotics.com/products/gmpw_deal/ 2
connectors female headers > 20 http://www.sparkfun.com/products/115 1
connectors male headers > 20 http://www.sparkfun.com/products/116 1
sensors Infrared Proximity Sensor - Sharp GP2Y0A21YK http://www.sparkfun.com/products/242 1
Capacitor Ceramic 22pF http://www.sparkfun.com/products/8571 2
batteryholder 9vsnap http://www.sparkfun.com/products/91 1
sensors QRE1113 Line Sensor Analog http://www.sparkfun.com/products/9453 2
LED Basic LED - 5mm laying around 1

Mechapad.png


eagle design files