Let's Make Robots!

code

Upcoming Webinar: Embedded Code Generation for AC Motor Controllers

ahollis70's picture

Cheers everyone,

Dropping this link just incase anyone is interested.  For what its worth, I have no professional affiliation with MathWorks outside that of using the software as a student.

Quoted from site -- " In this webinar we feature the development and implementation of a field-oriented controller for a permanent magnet synchronous machine (PMSM) using a real-time microcontroller. The workflow will show you how to:

Error coming up in code

Photolong's picture

copied this code from http://www.jeremyblum.com/2011/07/31/tutorial-13-for-arduino-liquid-crystal-displays/ but when i try to compile i get a error at void set up {}( function definition dose not declare parameters) i highlighted the part that gets this error ... but i can figure out whats wrong ...

 

/*

*RS: Pin 2

*EN: Pin 3

*D4: Pin 4

*D5: Pin 5

*D6: Pin 6

Why won't it vark?

Aaronsuper1's picture

I've made a development bot named Arcee as some of you know, now i've added an AmandaLDR to it for obstacle avoiding.The LEDs on the sensor are very bright and blue in colour. The bot won't use a servo to pan the sensor, it'll simply rotate itself.

The problem is, I don't think it's working. But the sensor works, oddly enough. It can turn an LED on at a threshold. But once implemented into an obstacle avoidance code it dosen't seem to work.

The code is attached below.

 

 

Arduino to processing

flare's picture

So I have a Sharp IR sensor connected to my Arduino, feeding to my pc the values of its analog input, via the Serial connection.

To do this, I'm using the Serial.write() command. I want to be able to read these values into processing, but when I use the Serial.read() command in Processing, the values it picks up are nothing like what the Arduino Serial monitor is giving me, and are unaffected by the IR sensor.

What am I doing wrong, and how can I get processing to read these values from the IR sensor?

Any help is appreciated.

IR RC code problems...

Aaronsuper1's picture

 

 

#include <IRremote.h>

#define m1F 6

#define m1R 7

#define m2F 5

#define m2R 8

 

long F = 1979994096;

long L = 1979994056;

long R = 1979994048;

long B = 1979994076;

long S = 1979994080;

int RECV_PIN = 4;

 

IRrecv irrecv(RECV_PIN);

 

decode_results results;

 

void setup()

{

  pinMode(13, OUTPUT);

  pinMode(m1F, OUTPUT);

  pinMode(m1R, OUTPUT);

  pinMode(m2F, OUTPUT);

Servo coding (solved)

It is working now, thanks to everyone who helped me out!!!

 

 

I am trying to make my servo work,but if I start my arduino, with code and servo attached, it just goes to one position and stays there twitching. Can someone help me?

second try

My first hand written code.

Aaronsuper1's picture

I have just written my first code in Arduino IDE. The code should make a servo move to 180 degrees wait one second and then move back to 0 degrees and repeat.

Here it is :

 

#include <Servo.h>

 

Servo servo1;

int posR = 179;

int posL = 0;

 

void setup()

{

  servo1.attach(9);

}

 

void loop()

{  

  { 

     servo1.write(posR);

     delay(1000);

  }

  {

Support site for DAGU kits and products

OddBot's picture

G'day Everyone,

I have been designing products for DAGU for over 2 years now. During this time I have always tried to provide technical support and help in general here on LMR. I will still continue to do so but previously I had trouble uploading manuals because of upload limits.

I have been revamping the code for Mr. Tidy and it has grown large enough (23Kb when compiled) to be a real headache to scroll through. I know that some IDE's solve … Read more

sensor jitter problems? Let's fight back.

Janson's picture

I wrote a tiny function in Arduino-C for my sensor-jitter problems. You can smooth out your sensor readings with this little function. You can input the smoothness and then get back the smoothed sensor value.

If somebody needs it - here it is:

// Jan Przybilla, Rosk, Farbtonstudio.de
// SSR - Smooth Sensor Readings
// Fight the (((Jitter)))!

Saves time and avoids many related coding mistakes.
I have been learning about programming for years. More recently, I have been taught that magic numbers or constants should not be hard coded deep in your program. … Read more

Area mapping

Markamas's picture

I have (that is relative because I have not yet ordered my first parts from Robotshop) a PING ultrasonic sensor. I'll be having an arduino mini - though I'll no doubt buy something bigger after - and I wonder if I can efficiently make my upcoming rover (differentially driven, nothing special really) map it's surrounding area using a grid. Is it possible or will I run short on memory with the arduino mini? And more importantly, I need help with the code (I have 0 experience with code, though I have enough theory I guess...). Any suggestions are appreciated.

Picaxe code

TheBromz's picture

Hi all,

I've been busy over the past few days studying the Picaxe manuals and trying to understand the coding. I keep reading about how easy it is and it's even called basic, but my problem is, I don't understand any of it.

My electrical and mechanical skills are enough to get me by, but this programming makes no sense to me what so ever.

I've Googled in an attemp to find online tutorials, that doesn't seem to help either.

Can anyone explain how they learned the Picaxe basic coding? That might help me.

Thanks,

The Bromz.

Homebrew tilt compensation?

1ceman's picture

Honeywell's datasheet on the HMC6343 compass states that tilt compensation is made using data from a built-in three axis accelerometer. I thought that a cheaper three-axis magnetometer- accelerometer combination is much more reasonable for small scale projects, so my question is: What kind of calculations do I need to perform to get a decent degree of accuracy?

 

Doubts about software development for robots

mif's picture

Hi LMRtians

After doing some programming for my first robot I was wondering (maybe because of my computer science background) if someone uses some kind of notation or software development methods at the hour of programming the robot.
 
When you are programming simple things like the Start Here Robot (http://letsmakerobots.com/start) it is easy to program a sequence of actions:

While
  Condition 1: gosub Action 1
  Condition 2: gosub Action 2
End

From Picaxe to Arduino

OddBot's picture

When I joined LMR I had just written my first picaxe program. After 16 months I have finally crossed over to Arduino. The biggest problem I found was that all the commands were not in one neat package like the picaxe manuals (Manual 2 in particular).

Listen to LMR!

gimmelotsarobots's picture
I came across a website called www.codeorgan.com that turns the code of any website into music! put the url for the LMR homepage in, and it sounds pretty good. I wouldn't expect less from LMR.

Stupid / Beginning Questions

I'm somewhat new to arduino and finally found out about libraries.  Unfortunately I have looked for instructions on how to create one and how to upload an existing library.  So if someone could give me step-by-step instructions on how to get this library i have here sitting on my desktop to something i can use in code. (please dummy-down the instructions).

It would also be helpful if someone could provide me with a small sample code for a robot that uses Ping)))

Code Repository!

jair2k4's picture

Can we get everyone who has got their code to successfully run to post their files here? Ive been looking all over the site for a central area for code, and I cannot find one. If there is one, point me in that direction, if not, lets all start posting here!

Try not to paste lines of code here, lets keep it clean. uploaded files only please!

Format:

Name of code,

What it's for

File (zip or IDE compatible file)

 

What do you guys think?

Arduino Motor Control Code Help

electrictape22's picture

I am currently using a arduino duemilanove, and it is awesome. I have been playing around with it for a couple of days now, and I really like it. Anyways I figured it was time to start to building a robot. I decided to start with the motors. For the motor control I decided to use guibot's tutorial. It worked fine, but the motors only traveled in one direction. Because I wanted the motors to also travel in reverse too I decided to experiment with my own code (on only one motor) that looks something like this:

The challenge of building a 1st bot..

starscorched's picture

08/07/09

I got my arduino mega in the post a few days back and having been playing around lighting up LEDs. Thought id get started with constructing my 1st bot. Hence i rigged up 2 motors, a dual mc33887 motor driver, a 6v supply and the mega board. Uploaded a sample code to see if it would turn the motors. Voila!! Nothing happens. Nothing whirring, no sound, no ecstasy. No nothing. 

Its quite obvious that my bot wont perform with stationary wheels.

Still trying to find a solution. Images of connection, mc33887 truth table and sample code below.

what is wrong with my code?!

PeterJacob's picture

i dont know what's wrong with my code!

i made a simple code that should make my robot simply avoid walls, stuff etc.

i placed SC-QR-1 (my robot's name) upside-down and pressed [F5] (the "run" shortcut) and watched him move his cute little robot legs..     WTF?

the new code seemed to work untill the walk part was over and he started to turn..    ..left.        and then again left and again and again..    etc.

he is suposed to keep walking!!!

What wrong with my code???

#include <Servo.h>

Servo myservoL;
Servo myservoR;
int myservo = 2;
int myAngle;
int pulseWidth;

void setup()
{
  pinMode(myservo, OUTPUT);
  myservoL.attach(9);
  myservoR.attach(10);
}

void servoPulse(int myservo, int myAngle)
{
  pulseWidth = (myAngle *10) + 600;
  digitalWrite(myservo, HIGH);
  delayMicroseconds(pulseWidth);
  digitalWrite(myservo, LOW);
}

Continuous Rotation Servo & Picaxe

Ok, so I finally got all my gear set up to build robot numero uno, but Im goin friggin nuts trying to control my continuous rotation servos from parallax. Im using a picaxe 18x to produce the code, but no matter what pulsout or servo commands I use, my servo's only go clockwise.I NEED them to be able to go counterclockwise  for my differential drive train to work right. I have read every post on LMR about servos and have tried a lot. I have read their parallax data sheet and that they should respond based upon the pulse width, but no go.