Arduino Diecimila Questions

http://www.arduino.cc/en/Main/ArduinoBoardDiecimila

ArduinoDiecimila400.jpg

which ports can support servo control? and where are they located?

I'm getting one leter this week, and I have absolutely no idea how it works.

 

I don’t know them but i
I don’t know them but i guess any digital out would be fine (top row). You have to find the right command though (no idea if arduino has servo libraries, but of course there is a way to)

**all i need are 3 servos. **

to drive it. can i run the board and 3 servos, and sharp ir on a 9V box battery, or do i need to make myself a power-shield?

im thinking of…
making a homemade ard. proto shield with a board from my radioshack store (they carry at least 1 useful thing) that has a seperate power supply. from what you have told me, the 9v wouldnt last long even if it did work, so i think 2 power supplies are the way to go.

Rudolph is right, a single

Rudolph is right, a single 9v would power everything for about 30 minutes maybe. Dual supplies is the way to go.

If you enjoy AVRs and C style programming you can get plain AVR chips and turn your Arduino into a programmer following these instructions. I use it and it works like a charm.

and that does what?

i thought i could program the ard. straight out of the box! pretend im an idiot and explain this to me in moron terms

also, what do libraries do?

Yeah you can with the

Yeah you can with the Arduino because it has a bootloader. Just plug in the USB cable and upload the program from the Arduino software.

But if you want to make something permanent, you can pull the chip out of the board and put it on your own diy board, then buy more blank chips for $4 each to put back in the Arduino board. With the above link you can turn the blank chip into an Arduino chip using only the arduino board and some cables. Its the same principle as turning a plain PIC into a picaxe chip. </p><p>Oh, libraries are ways of sharing code easily. Also they tidy up programs by hiding the stuff you dont need to see. For an ultrasound sensor, instead of putting 10 lines of code in the main program you could put it in a library. Then when you make your 2nd 3rd 4th etc bots with the same ultrasound sensor you can import the same library.

If you have no idea how to

If you have no idea how to work with Arduino, I suggest to take a look into these tutorials, I started with them and even today they are very usefull. You will have everything very well explained, starting by blinking an LED, to work with buttons, potenciometers, servos, motors, and so on :wink:

http://todbot.com/blog/bionicarduino/

http://todbot.com/blog/spookyarduino/

oooh…
so what you are talking about is taking an ATMega and loading the program, then soldering it onto a board? then using the board only as a bridge between the PC and the ATMEGA?

so to move it back and forth, i’d do something like this:

void loop() {
// cycle through every angle (rotate the servo 180 slowly)
for (myAngle=0; myAngle<=180; myAngle++) {
servoPulse(9, myAngle);

}
delay(1000);
}

 

What this does is…

for (myangle…) it tells a non continuous rotation servo what to do anglewise.

then it pulses the servo through that arc, pulsing once every second. but how would i apply these angles to a continuous rotation servo? stop pretending, cuz i am an idiot at this

You don’t use angles for a

You don’t use angles for a continuous rotation modded servo, what used to be the angle value now sets the speed of rotation. If you told the servo to go to ‘angle’ 180°, it would run maximum speed in one direction, while ‘angle’ 0° would make it run maximum speed in the other direction. 90° would make the servo stop completely, and all the other angles between 0° and 180° would make the servo run forward or backward at a speed less than maximum.
If you used the code you posted above for a modded servo, the servo would run one way at full speed, gradually slow down and eventually reverse until it was running full speed the opposite way (for one loop).

That looks pretty good! You

That looks pretty good! You should put a delay inside the loop like below otherwise your for loop will go through as fast as the processor can manage a servo output command.

void loop()
{
// cycle through every angle (rotate the servo 180 slowly)
for (int myAngle=0; myAngle<=180; myAngle++)
{
servoPulse(9, myAngle);
delay(10);
}
delay(1000);
}

In C you need to initialize variables before using them by giving them a type. int myAngle says myAngle is a new variable of integer type. for(int myAngle =0…) works fine and makes myAngle a local variable… local to only that specific for loop. That way when the for loop is finished, the variable is destroyed and that memory is free for somewhere else. You CAN make myAngle global though by putting int myAngle; right at the top of your program. That way it keeps its value even after the loop is done, but if you arent gonna use it outside the loop its a bit of a waste.

 

okay… sounds good…

and the { and} specify a certain loop in the program right? like if i had a few of the above program, it would do one, then move on to the next, then…

the variable thing is the same deal in basic. sorta. you give it a type, bit, byte or word…

now what about libraries? what purpose do they serve?

Yeah {} circle loops and if

Yeah {} circle loops and if statements plus some others, switch etc. I like to keep them on their own lines so I can match them in pairs easily.

I answered the libraries thing up further. Look inside the \arduino-0015\hardware\libraries directory for all the libraries that come with the default install. Look inside the servo library folder and open servo.h in a text editor. All those commands in "private" are only used inside the actual library, but the ones underneath "public" you can use in your program. If you open servo.cpp this is the guts of the library. All the actual code.

The curly brackets denote a

The curly brackets denote a block of code that is tied together, ie: everything inside the { stuff } brackets after void loop() is the block of code that will be executed every time the loop() function is called. The code inside { and } after the ‘for’ command is the code that will be executed every time the for loop is run.

Libraries are pieces of code that can be reused easily; adding a library is like copying and pasting that code into your own, but it’s tidier and more convenient (like if you update the library, all the programs that use that library will automatically use the updated copy).
Libraries are often used to provide pre-built commands to do something like, say, perform a certain set of calculations, or to control a particular type of servo, or something like that.

So if i made a library with my servo program

it would be a lot easier to insert it wherever i needed. starting to get it now…

now all i need is the Arduino itself! gui mailed it to me a buncha days ago

Thanks for all your help!