Skip to content

Carbot is Alive!

September 3, 2014

I did the first smoke test of Carbot this morning and it worked a treat:

Here’s a picture of the unit as tested.  The olduino is being powered by the serial cable.  The motor power is coming from a rechargeable battery pack from a cordless phone.  Everything is just sort of lying there unattached and i haven’t tried the sensor yet but I’m greatly encouraged.

14-09-02 carbot!

Here’s the code as adapted from an early arduino version of the carbot.  I mostly just changed the pin numbers in digitalWrite and took out pinMode calls since the olduino pins are all uni-directional.  I didn’t make any effort to modulate the motors, just turned them on and off and I think left and right are backwards but it worked, nothing blew up or even got warm!

#include <olduino.h>
#include <nstdlib.h>
int pwma=0,ain1=1,ain2=2; //drive left motor in1+ and in2- control direction
int pwmb=4,bin1=5,bin2=6; //drive right motor in1+ and in2- control direction

void  setdirection(int d1,int d2,int d3,int d4){ //set the motors to counter-rotating
  	digitalWrite(d1,HIGH);
  	digitalWrite(d2,LOW);
  	digitalWrite(d3,HIGH);
  	digitalWrite(d4,LOW);
}

void goforward(int howlong){
 	setdirection(ain1,ain2,bin1,bin2);
 	digitalWrite(pwma,HIGH); digitalWrite(pwmb,HIGH); //turn on both motors
 	delay(howlong*1000);
 	digitalWrite(pwma,LOW); digitalWrite(pwmb,LOW); //turn off both motors
}
 void turnright(){
 	setdirection(ain1,ain2,bin2,bin1);
	digitalWrite(pwma,HIGH); digitalWrite(pwmb,HIGH); //turn on both motors
 	delay(1000);
 	digitalWrite(pwma,LOW); digitalWrite(pwmb,LOW); //turn off both motors
}

void loop() {
 	goforward(2);
 	delay(100);
 	turnright();
 	delay(1000);
 }
void main(){
	asm("	seq\n");
	loop();
	asm("	req\n");
}
#include <olduino.c>
#include <nstdlib.c>


Update: nope, left and right are ok. Good thing, because the setdirection thing seems a bit tough to follow.

Advertisements

From → Uncategorized

One Comment

Trackbacks & Pingbacks

  1. Infrared vs Ultrasonic Sensors | olduino

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: