User Tools

Site Tools


digispark:tutorials:robot

Robot Kit Tutorial

Product Description:

bot1.jpg bot2.jpg bot17.jpg

This is an unassembled kit and requires basic soldering. This is designed for use with the Digispark Pro or Oak development board.

Parts:

Part Quantity Notes
Digispark Pro or Oak1
9 Pin Female Header 0.1“ Pitch2
3 Pin Female Header 0.1” Pitch1 (or 2) 2 ARE ONLY INCLUDED WITH: BT, BLE, and Pro WiFi Robots (see note)
9 Pin Stackable Female Header 0.1“ Pitch2 ONLY INCLUDED WITH: BT, BLE, and Pro WiFi Robots (see note)
3 Pin 3.5mm Screw Terminal 1
2 Pin 3.5mm Screw Terminal 3
Wings Shield PCB 1
Motor Driver 1
Bag of Hardware 1
Small Machine Screw for Mounting Digispark and Motor Driver 2 or 1 May be separate from hardware bag, only 1 with Oak Robot
Small Nut to go with Machine Screws 2 or 1 May be separate from hardware bag, only 1 with Oak Robot
1x40pin male 0.1” pitch header 9 pins worth NOT INCLUDED WITH: BT, BLE, and Pro WiFi Robots (see note)
14“ Piece of Solid Core Wire 2 Color is random, but the two pieces should be different colors
Wheels 2
Swivel Wheel 1
Acrylic Base 1
Battery Holder 1
Male to Female Jumper Wire 6 May be attached together, may not be
Motors 2
BT, BLE, or Pro WiFi kit - if applicable 1 These may or may not be in the bag with the robot parts, please check the envelope well

NOTE ON HEADERS: Basic Robot kits were supposed to ship without stackable headers and with a 1×40 pin male header strip. Many shipped with the stackable headers instead - we encourage you to use some extra male headers from another kit to complete the Wings Kit and then use the stackable headers for any Pro kit you have (you end up with a free set of stackables!) - if you don't have any male headers to spare, please contact us so we can make it right.

Soldering: If you are new to soldering we recommend the following tutorials: Soldering Basics (http://www.sparkfun.com/tutorials/106) and Soldering Crash Course from the folks at Sparkfun (http://www.sparkfun.com/tutorials/354). How to solder from the Curious Inventor: http://store.curiousinventor.com/guides/How_to_Solder

Adafruit has this excellent guide that starts with the tools needed and then shows detailed pictures, including some of the common problems that beginners experience (http://learn.adafruit.com/adafruit-guide-excellent-soldering)

We assume for these assembly instructions that you know the basics of thru-hole soldering. If you don't check out the links above, these boards are very easy to solder - we promise!

Assembly:

Check that you have all parts listed above - they may be located in different bags or even loose in the package.

bot1.jpg bot2.jpg

Prepare the shields:

Solder the female (non-stackable) headers to your Digispark Pro.

Assemble the Wings Kits - using the male headers from the BLE, BT, WiFi Kit or extra ones - per the instructions here: http://digistump.com/wiki/digispark/tutorials/wings NOTE On the Oak the 5V pin is actually for 3.3V

Assemble the BT, BLE, or WiFi kit (using the correct tutorial for that kit) if applicable - using the included 9 pin stackable headers and the extra 3 pin female header. See the following photos for an example of how it should look with those headers (this is a BT shield, but the BLE and WiFi header setup would be the same):

blestack1.jpg blestack2.jpg blestack3.jpg

Remove the paper from the Acrylic base: Carefully peel the paper off each side of the Acrylic base - it is to protect it in shipping. It is left on for these photos, so that it shows up on camera.

Cut the two approx. 14” lengths of wire in half, so you have two of each color. Strip all ends of the wires. Solder two wires (one of each color) to each motor, on to the little copper colored metal tabs. Apply a fair amount of solder, and be careful, the tabs are somewhat delicate and can break off the motor.

bot3.jpg bot4.jpg

Find the two metal blocks in the hardware bag and the four longest bolts. Pass the bolts through the motor housing as shown - and through the block - put nuts on the end of the bolt that comes through the block and tighten.

Repeat for the other motor, flipping the side the two holes on the narrow top of the block are on, so that they line up with the holes in the acrylic when the motors are mounted as shown.

bot5.jpg

Mount the motors to the acrylic base as shown, using two (per mount) of the short pan head screws. Thread each screw in a little, and then tighten alternating between the screws - this will ensure they are able to tighten despite the natural variances in acrylic.

bot6.jpg

Carefully press the wheels on to the motors.

bot7.jpg

Attach the 4 brass standoffs to the swivel wheel using 4 nuts.

bot8.jpg

Attach the swivel wheel assembly as shown to the Acrylic, using 4 pan head screws.

bot9.jpg

Attach the battery holder as shown using two pan head screw going down through it and the acrylic into two nuts. You will have to push the screws down with a screwdriver, while holding the nuts in place to get them to “bite” and tighten.

bot10.jpg

Mount the Motor Driver board to the Acrylic base using one of the thinner screws and smaller nuts.

bot11.jpg

Mount the Digispark Pro board to the Acrylic base using one of the thinner screws and smaller nuts. (Note: Skip this step with the Oak - it lacks mounting hole - you may want to use zip-ties, tape, or glue to mount it)

bot12.jpg

Non-Basic Kit: Attach the BLE, BT, or WiFi kit to the Digispark Pro and then the Wings shield on top of that. As shown (BT in this example, but the stack order is the same for BLE and WiFi).

robotstack.jpg

Basic Kit: Attach the Wings Shield kit to the Digispark Pro. As shown.

bot14.jpg

Attach the wires from one motor to the screw terminals on the Motor Driver labeled “A”, and from the other to the ones labeled “B”

bot13.jpg

Attach the jumper wires from the VCC and GND pins of the Motor Driver to the VIN and GND screw terminals on the Wings Shield. Also attached the black wire from the battery holder to the GND terminal on the wings shield. And the red wire to the VIN terminal on the Wings shield. It may be easier to solder the battery wires to the pins of the jumper wires before putting them both in the screw terminal together.

Attach the jumper wires from the A-A and A-B pins on the Motor Driver to Pin 0 and Pin 2 of the Wings shield, respectively.

Attach the jumper wires from the B-A and B-B pins on the Motor Driver to Pin 1 and Pin 5 of the Wings shield, respectively.

bot14.jpg

Use tape, glue, or zip-ties (not included) to organize the wires if desired.

bot15.jpg bot16.jpg

Insert batteries (before plugging the Digispark into the computer, or remove the wings shield before plugging it in!) - and then plug the Digispark Pro into the computer and upload the test code. If the wheels are not moving the same direction then flip the wires for one motor going into the motor driver. If both wheels are going the wrong way (backward instead of forward), then flip both sets.

Your Robot is Complete!

bot17.jpg

Programming:

NOTE: The example included with the Oak is incorrect - please use the Oak example below.

Copy and upload the following sketch. This sketch will cause the bot to cycle through each of its movement abilities at full speed, 5 seconds each.

BT, BLE, and WiFi Examples included with the IDE.

For the Digispark/Digispark Pro:

void setup() {
  // put your setup code here, to run once:
  botInit();
}
 
 
void loop() {
  // put your main code here, to run repeatedly:
  botForward(255); //speed can be any value from 0 (stopped) to 255 (full)
  delay(5000);
  botReverse(255);
  delay(5000);
  botRight(255);
  delay(5000);
  botHardRight(255);
  delay(5000);
  botLeft(255);
  delay(5000);
  botHardLeft(255);
  delay(5000);
  botStop();
  delay(5000);
}
 
void botForward(int botSpeed){
 digitalWrite(2, HIGH); 
 digitalWrite(5, HIGH);
 analogWrite(0, 255 - botSpeed);
 analogWrite(1, 255 - botSpeed);
}
 
void botReverse(int botSpeed){
 digitalWrite(2, LOW); 
 digitalWrite(5, LOW);
 analogWrite(0, botSpeed);
 analogWrite(1, botSpeed);
}
 
void botRight(int botSpeed){
 digitalWrite(2, LOW); 
 digitalWrite(5, HIGH);
 analogWrite(0, 0);
 analogWrite(1, 255 - botSpeed);
}
 
void botHardRight(int botSpeed){
 digitalWrite(2, LOW); 
 digitalWrite(5, HIGH);
 analogWrite(0, botSpeed);
 analogWrite(1, 255 - botSpeed);
}
 
void botLeft(int botSpeed){
 digitalWrite(2, HIGH); 
 digitalWrite(5, LOW);
 analogWrite(0, 255 - botSpeed);
 analogWrite(1, 0);
}
 
void botHardLeft(int botSpeed){
 digitalWrite(2, HIGH); 
 digitalWrite(5, LOW);
 analogWrite(0, 255 - botSpeed);
 analogWrite(1, botSpeed);
}
 
void botStop(){
 digitalWrite(2,LOW); 
 digitalWrite(5,LOW);
 analogWrite(0,0);
 analogWrite(1,0);
}
 
void botInit(){
 pinMode(0,OUTPUT);
 pinMode(1,OUTPUT);
 pinMode(2,OUTPUT);
 pinMode(5,OUTPUT);
}

For the Oak:

void setup() {
  // put your setup code here, to run once:
  botInit();
}
 
 
void loop() {
  // put your main code here, to run repeatedly:
  botForward(1023); //speed can be any value from 0 (stopped) to 1023 (full)
  delay(5000);
  botReverse(1023);
  delay(5000);
  botRight(1023);
  delay(5000);
  botHardRight(1023);
  delay(5000);
  botLeft(1023);
  delay(5000);
  botHardLeft(1023);
  delay(5000);
  botStop();
  delay(5000);
}
 
void botForward(int botSpeed){
 digitalWrite(2, HIGH); 
 digitalWrite(5, HIGH);
 analogWrite(0, 1023 - botSpeed);
 analogWrite(1, 1023 - botSpeed);
}
 
void botReverse(int botSpeed){
 digitalWrite(2, LOW); 
 digitalWrite(5, LOW);
 analogWrite(0, botSpeed);
 analogWrite(1, botSpeed);
}
 
void botRight(int botSpeed){
 digitalWrite(2, LOW); 
 digitalWrite(5, HIGH);
 analogWrite(0, 0);
 analogWrite(1, 1023 - botSpeed);
}
 
void botHardRight(int botSpeed){
 digitalWrite(2, LOW); 
 digitalWrite(5, HIGH);
 analogWrite(0, botSpeed);
 analogWrite(1, 1023 - botSpeed);
}
 
void botLeft(int botSpeed){
 digitalWrite(2, HIGH); 
 digitalWrite(5, LOW);
 analogWrite(0, 1023 - botSpeed);
 analogWrite(1, 0);
}
 
void botHardLeft(int botSpeed){
 digitalWrite(2, HIGH); 
 digitalWrite(5, LOW);
 analogWrite(0, 1023 - botSpeed);
 analogWrite(1, botSpeed);
}
 
void botStop(){
 digitalWrite(2,LOW); 
 digitalWrite(5,LOW);
 analogWrite(0,0);
 analogWrite(1,0);
}
 
void botInit(){
 pinMode(0,OUTPUT);
 pinMode(1,OUTPUT);
 pinMode(2,OUTPUT);
 pinMode(5,OUTPUT);
}
digispark/tutorials/robot.txt · Last modified: 2016/06/09 12:03 (external edit)