Loading...
  Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: variable scope arduino vs c++ on: April 30, 2013, 09:41:32 pm
i guess what i'm asking, is there a way to keep variables local to void loop without them being screwed up by a redecoration when void loop repeats?

or is the only good way to work with void loop is using global variables.

(from what i have read about c++; int main is where one would declare local variables and int main does not repeat unless the programmer makes it repeat with some sort of a loop where as long as the variable declarations are kept outside that loop there is no problem and the variables stay local to int main)
2  Using Arduino / Programming Questions / variable scope arduino vs c++ on: April 30, 2013, 09:29:07 pm
i have a few questions on variable scope and the differences between arduino and c++.
first any variable declared outside of all functions is a global variable. i totally get that.

a variable declared inside a function is a local variable that can only be accessed by that function. this is where it gets fussy.

for example

 
Code:
void loop()
{ int bob; // this declares an integer bob
int steve = 5; // this declares the integer steve and sets it to five}

if i were to run this code the declaration of bob as void loop repeats would not affect the value of bob after a value is stored.
but would steve be redeclared with the value 5 every time void loop repeats?

if it does always reset to 5 how can variables get an initial value inside a local scope without declaring them globally?
3  Using Arduino / Sensors / IR sensor as a cheap lidar on: April 25, 2013, 09:50:08 pm
has anyone tried to use a sharp IR sensor as a cheap form of lidar?
i was thinking that if this sensor is mounted on a servo a FOR loop could advance the servo one degree at a time and take a reading from the IR sensor populating an array with the readings.

does this sound like i would work or are there pitfalls that i'm not seeing?
4  Using Arduino / Programming Questions / Re: bootloader delay on: April 15, 2013, 06:56:24 am
as accurate as possible.
i'm competing in a sumo bot competition and there is a five second delay before starting.
if i start too early i'm disqualified.
if i start a second late the other bot has a jump on me.
5  Using Arduino / Programming Questions / Re: bootloader delay on: April 14, 2013, 07:52:36 pm
how can i find out what bootloader i am using and where do i find the delay for that boot loader.

i'm using an arduino uno rev3 with ATmega328
the boot loader was installed by arduino software version 1.0.4

(i have a programmer and i have removed and replaced the bootloader many times. but in my current project the arduino board is buried beneath a shield so i can't access the programming connector without major disassembly. i do have easy access to the regular usb port and that is the way i would like to program it in this case.)
6  Using Arduino / Programming Questions / bootloader delay on: April 14, 2013, 06:28:36 pm
i need a sketch on my arduino uno to start exactly five seconds after i turn on the power.
is there a way to see how long the bootloader waits to see if a sketch will be uploaded before starting the currently loaded sketch?
my plan is to add a delay at the very end of void setup that way the sketch start time would be
(bootloader) plus (delay) = 5 second delay before void loop
this way if i know the bootloader delay i can then do the math for the added delay

7  Using Arduino / Motors, Mechanics, and Power / Re: arduino motor shield on: December 11, 2012, 01:14:29 pm
what i'm working on is a sumo bot. (two robots go into a a round ring and try to push each other out, the robots must be fully autonomous). i want to make the code with as few lines as possible to allow for the greatest speed. they way i'm designing my code is that when the bot detects an object it will drive at it full speed. as soon as no object is detected it will kick on the brakes because it is very easy to drive out of the ring. then all that needs done is one of the motors switched into reverse and to turn the brakes off the cause the robot to spin locating the target. then another quick tap of the breaks and switch the one motor back into forward and off we go after the opponent. in this scenario the motors are always at full speed and i don't constantly have to command the PWM up or down.

does this sound reasonable?
8  Using Arduino / Motors, Mechanics, and Power / arduino motor shield on: December 10, 2012, 10:30:50 pm
i am using an arduino motor shield r3 to drive two brushed dc motors.

on the motor shield can the brake function be engaged without stopping the PWM command to the motors.
for example if the robot is driving forward full throttle (PWM at 255) and a obstacle is detected and i want the robot to stop until the obstacle is gone can i engage the brakes with out dropping the PWM to zero. so when the brakes are disengaged the robot will continue full speed. or will doing so fry the board by short circuiting it.

is the board protected?
9  Using Arduino / Motors, Mechanics, and Power / Re: best way to power arduino on: October 05, 2012, 04:43:49 pm
i will have five parallax ultrasonic ping sensors on the 5v rail. the data sheet rates them at 35mA max for a max total of 175mA.
(altho i'm not sure how much current it takes to command the motor shield)
10  Using Arduino / Motors, Mechanics, and Power / best way to power arduino on: October 05, 2012, 04:09:26 pm
i am building a sumo bot. for this i am using an arduino uno rev3 board, grove sensor shield, two 12v 1.5A motors and i want to use an arduino motor shield. from all the documentation that i read if using a 12V battery it is recommended to cut the "Vin Connect" jumper because 12V is too much for the arduino board.

in this scenario what is the best way to power the board?

the two options i can think of are:
1: run the 12V power directly to the motor shield. install a 9V regulator parallel to the battery and using a 2.1mm center-positive plug connect it to the board. (is this too complicated of a solution?)

2: run the 12V power directly to the motor shield. install a 5V regulator parallel to the battery and send the 5V and Ground to one of the unused connectors of the sensor shield. (would back feeding the board this way fry anything? or would it cause problems with programming it if the external power is still hooked up?)
Pages: [1]