Skip to main content

Building a drawing robot in Geekcon 2015

On the last GeekCon 2015, me and my brother built a drawing robot.
Can draw on a large scale pages, basically working the same way Logo (Computer Language) Turtle is working. Can go forward, backward and turn around. Can raise the pen or lower it in order to start drawing.

Here are some pictures, explanations and code.

We used the Arduino Uno (actually Funduino Uno compatible) over a Maze car  rack bought in Deal Extreme. Using the Keyes L298 driver for the DC motors and a Servo motor using the original Servo.h library kit from Arduino.









Some external references helping us to go on:


Here is the code:
Also can be seen in Github:

// connect motor controller pins to Arduino digital pins
// motor one
int enA = 11;
int in1 = 2;
int in2 = 3;
// motor two
int enB = 6;
int in3 = 4;
int in4 = 5;
// servo pen
int servoPin = 13;
int speed = 255;


//Include for servo
#include   // servo library
//Define Servo
Servo servo;  // servo control object

void set_speed(int pin, int speed)
{
  //if(pin == enA)
  //  analogWrite(pin, 200);
  //else
    digitalWrite(pin, HIGH);
}


void setup()
{
  Serial.begin (9600);

  servo.attach(servoPin);
 
  // set all the motor control pins to outputs
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
}

void forward(int duration)
{
  Serial.println("Forward");
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  set_speed(enA, speed);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  set_speed(enB, speed);
  delay(duration);
}
void right(int duration)
{
  Serial.println("Right");
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH); 
  set_speed(enA, speed);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  set_speed(enB, speed);
  delay(duration);
}
void left(int duration)
{
  Serial.println("Right");
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW); 
  set_speed(enA, speed);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  set_speed(enB, speed);
  delay(duration);
}
void sstop(int duration)
{
  // now turn off motors
  Serial.println("Off");
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW); 
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
 
  delay(duration);
}
void drawSquare()
{
  Serial.println("drawSquare start");

  // malben - starts from the lower left corner
  forward(1100);
  right(270); 
  forward(800);
  right(270);
  forward(1100);
  right(270);
  forward(800);
  right(270); 
}
void drawZigzag()
{
  Serial.println("drawZigzag start");

  // forward zigzag
  right(100);
  forward(300);
  left(200);
  forward(300);
  right(200);
  forward(300);
  left(200);
  forward(300);
  right(100);
}

void penDown()
{
  servo.write(90);
  Serial.println("Pen Down");
}

void penUp()
{
  servo.write(180);
  Serial.println("Pen Up");
}

void loop()
{
  penUp();
  delay(7000);
 
  penDown();
  drawSquare();

  penUp();
  sstop(1000);
  right(200);
  forward(300);
  left(200);

  //sstop(1000);

  penDown();
  drawZigzag();

  sstop(1000);
}



Comments

Popular posts from this blog

Using phpword to merge two Mircrosoft Office Word .docx documents

How to combine or embed and insert another .docx file (Microsoft office docx word document) into another one using PHPWord Joining two .docx document using php ( phpword library ) $mainTemplateProcessor = new \PhpOffice\PhpWord\TemplateProcessor("file1"); //$mainTemplateProcessor ->setValue('var_name', $value); $innerTemplateProcessor = new \PhpOffice\PhpWord\TemplateProcessor("file2"); //$innerTemplateProcessor->setValue('var2_name', $value2); // extract internal xml from template that will be merged inside main template $innerXml = $innerTemplateProcessor->gettempDocumentMainPart(); $innerXml = preg_replace('/^[\s\S]*<w:body>(.*)<\/w:body>.*/', '$1', $innerXml); // remove tag containing header, footer, images $innerXml = preg_replace('/<w:sectPr>.*<\/w:sectPr>/', '', $innerXml); // inject internal xml inside main template $mainXml = $mainTemplateProcessor->gettempDocumentMainPart(...

Bypassing the error by "go get" "tls: failed to verify certificate: x509: certificate signed by unknown authority"

When I was trying to download dependencies for my go project in an old Ubuntu machine I was getting this error all the time: "go: gopkg.in/alexcesaro/quotedprintable.v3@v3.0.0-20150716171945-2caba252f4dc: Get "https://proxy.golang.org/gopkg.in/alexcesaro/quotedprintable.v3/@v/v3.0.0-20150716171945-2caba252f4dc.mod": tls: failed to verify certificate: x509: certificate signed by unknown authority" Which the main part of it was go get failing to authenticate: " tls: failed to verify certificate: x509: certificate signed by unknown authority " I tried many things but couldn't make it work until I found the way: export GOINSECURE="proxy.golang.go" This will tell go get to ignore certification validity. Then export GOPROXY=direct This will tell go get to by pass proxy Then git config --global http.sslverify false And only after those I could run again: go get And it worked

Accessing Windows Share (Samba) From Linux (XFCE) using Thunar

In order to access samba (windows share) from Linux XFCE using Thunar file browser you need to: 1. Install samba client sudo apt install smbclient 2. Run: sudo modprobe cifs 3. Open thunar and access the share: smb://IPADDRESS/sharename e.g.: smb://192.168.1.1/photos 4. Type in the username / password in the prompt window Some helpful information: https://forum.manjaro.org/t/thunar-how-do-i-access-folders-shared-on-windows-computers/116649/9