User Tools

Site Tools


digispark:tutorials:robot

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
digispark:tutorials:robot [2014/12/06 13:50]
digistump
digispark:tutorials:robot [2016/06/09 12:03] (current)
Line 6: Line 6:
 [[https://​s3.amazonaws.com/​digispark/​images/​m/​bot17.JPG|{{https://​s3.amazonaws.com/​digispark/​images/​t/​bot17.JPG}}]] [[https://​s3.amazonaws.com/​digispark/​images/​m/​bot17.JPG|{{https://​s3.amazonaws.com/​digispark/​images/​t/​bot17.JPG}}]]
  
-This is an unassembled kit and requires basic soldering. This is designed for use with the Digispark development board, which is not included.+This is an unassembled kit and requires basic soldering. This is designed for use with the Digispark ​Pro or Oak development board.
  
 =====Parts:​===== =====Parts:​=====
  
 ^ Part       ^ Quantity ​         ^Notes^ ^ Part       ^ Quantity ​         ^Notes^
-| Digispark Pro|1| | +| Digispark Pro or Oak|1| | 
 | 9 Pin Female Header 0.1" Pitch|2| |  | 9 Pin Female Header 0.1" Pitch|2| | 
-| 3 Pin Female Header 0.1" Pitch|1 (or 2)| 2 ARE ONLY INCLUDED WITH: BT, BLE, and WiFi Robots (see note) |  +| 3 Pin Female Header 0.1" Pitch|1 (or 2)| 2 ARE ONLY INCLUDED WITH: BT, BLE, and Pro WiFi Robots (see note) |  
-| 9 Pin Stackable Female Header 0.1" Pitch|2| ONLY INCLUDED WITH: BT, BLE, and WiFi Robots (see note) |+| 9 Pin Stackable Female Header 0.1" Pitch|2| ONLY INCLUDED WITH: BT, BLE, and Pro WiFi Robots (see note) |
 | 3 Pin 3.5mm Screw Terminal |1| | | 3 Pin 3.5mm Screw Terminal |1| |
 | 2 Pin 3.5mm Screw Terminal |3| | | 2 Pin 3.5mm Screw Terminal |3| |
Line 20: Line 20:
 | Motor Driver |1| | | Motor Driver |1| |
 | Bag of Hardware |1| | | Bag of Hardware |1| |
-| Small Machine Screw for Mounting Digispark and Motor Driver |2| May be separate from hardware bag| +| 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| May be separate from hardware bag| +| 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 WiFi Robots (see note)  |+| 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| | 14" Piece of Solid Core Wire |2| Color is random, but the two pieces should be different colors|
 | Wheels |2| | | Wheels |2| |
Line 30: Line 30:
 | Male to Female Jumper Wire |6| May be attached together, may not be| | Male to Female Jumper Wire |6| May be attached together, may not be|
 | Motors |2| | | Motors |2| |
-| BT, BLE, or WiFi kit - if applicable |1| These may or may not be in the bag with the robot parts, please check the envelope well|+| 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 1x40 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. **NOTE ON HEADERS:** Basic Robot kits were supposed to ship without stackable headers and with a 1x40 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.
Line 56: Line 56:
 Solder the female (non-stackable) headers to your Digispark Pro. 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+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.+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): 
 + 
 +[[https://​s3.amazonaws.com/​digispark/​images/​m/​blestack1.JPG|{{https://​s3.amazonaws.com/​digispark/​images/​t/​blestack1.JPG}}]] 
 +[[https://​s3.amazonaws.com/​digispark/​images/​m/​blestack2.JPG|{{https://​s3.amazonaws.com/​digispark/​images/​t/​blestack2.JPG}}]] 
 +[[https://​s3.amazonaws.com/​digispark/​images/​m/​blestack3.JPG|{{https://​s3.amazonaws.com/​digispark/​images/​t/​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
  
  
Line 98: Line 105:
  
 Mount the Digispark Pro board to the Acrylic base using one of the thinner screws and smaller nuts. 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)
  
 [[https://​s3.amazonaws.com/​digispark/​images/​m/​bot12.JPG|{{https://​s3.amazonaws.com/​digispark/​images/​t/​bot12.JPG}}]] [[https://​s3.amazonaws.com/​digispark/​images/​m/​bot12.JPG|{{https://​s3.amazonaws.com/​digispark/​images/​t/​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.+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).
  
-Basic Kit: Attach the Wings Shield kit to the Digispark Pro.+[[https://​s3.amazonaws.com/​digispark/​images/​m/​robotstack.JPG|{{https://​s3.amazonaws.com/​digispark/​images/​t/​robotstack.JPG}}]] 
 + 
 +Basic Kit: Attach the Wings Shield kit to the Digispark Pro. As shown. 
 + 
 +[[https://​s3.amazonaws.com/​digispark/​images/​m/​bot14.JPG|{{https://​s3.amazonaws.com/​digispark/​images/​t/​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"​ 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"​
Line 130: Line 142:
  
 =====Programming:​===== =====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:**
 +<code arduino>
 +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);​
 +}
 +</​code>​
 +
 +
 +
 +**For the Oak:**
 +<code arduino>
 +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);​
 +}
 +</​code>​
digispark/tutorials/robot.1417902642.txt.gz · Last modified: 2014/12/06 13:50 by digistump