I'd think it does just what you said (runs the outer loop twice then goes to 90° and STOPS). Instead it loops this sequence indefinitely.
Maybe as Matticus says it is indeed an Arduino thing and...
Type: Posts; User: 777funk
I'd think it does just what you said (runs the outer loop twice then goes to 90° and STOPS). Instead it loops this sequence indefinitely.
Maybe as Matticus says it is indeed an Arduino thing and...
It drives a stepper motor run by an arduino MCU chip.
I'd like it to cycle from 0 to 180 a couple times then land at 90. But it does it indefinitely.
Well the two sweeps (incr and decr q number of times) is what's needed. But after that (q number of times) I'd like it to stop and not continue forever. But I need the bracket at the end and at the...
I'd like to run this code only once instead of a loop. Is there a simple way to do this?
void loop() // Main Program
{
//// Two Sweeps
for (q = 0; q <=1; q += 1)
{
for(pos = 180; pos...
I have a program with some pretty repetitive blocks of code (i.e Loop A, Loop B, Loop C, then Loop A again... etc) , is it possible to define an entire loop as a single line/function?
Say I have...
That's quite a welcome! Thank you. Wow.
As far as reading, I've done some (Ritchie's book and a few others). I will have to do more. I am learning C and am in a rush on a quick project. I figured...
Is there no way to define an entire block of code as a command?
Sorry if this is a dumb question. I'm new to C.
Once again I'd like to condense a group of code into a single function. I'm a...
It is a check for the relay on or off and an exit if it is OFF.
But I'd like to abbreviate it a bit or represent it as a variable if it's possible.
i.e.
getout = that entire block of code
I'd like to run a block of code interspersed throughout a program and rather than making a mess in the program I'd like to define it as a variable. I'm not sure if that's the right terminology but...
Well I actually don't necessarily want it to execute all the way through any of the sub loops (and their are lots of them within the main while loop which is triggered by the HIGH pin) in my program...
Ok, now I have it in the while loop:
while (relaystate == HIGH)
{
// if Relay for the motor is high (5V) then run the pickup program)
Anyone have an example of how I would do this with a while?
My digital input trigger to start the while loop is working but it's going into the loop and never exiting. I guess that means (based...
That's not all of my code. It's pretty long so the braces may not all add up properly. I cut out most of the code just to give the idea.
I'm sure the indentation is horrible. It's a result of a...
Here's what I've got as the main bones of my code. I tried the Goto and bailout and it isn't working for some reason. It is not entering the while loop until the condition is met but once it's in, it...
One thing I didn't think of....
while loop
Would that do what I'm thinking?
I'm in the middle of righting a program for a servo motor. I'd like to use an if and else to have the motor exit the main program with a pin going low and I'd like it to do it immediately.
Right...
Great thanks guys! And it worked in real life with the hardware I'm working on (Arduino Microcontroller and a servo).
I've got this code and I'm trying to multiply something times 1.3 (float value)
Anyways, P is defined:
int p=0;
Here's the code:
Well shoot! Looks like my servo burned itself out so I'll have to continue the research later this week (got more ordered).
I finally got it to do what I've been trying to get it to do. But it seems to not be sweeping the entire degree range (around 40 degrees from 67 to 107).
void loop()
{
for (a...
Ok I changed it to x -= 1 and it's actually more within the range but it's not doing what I had hoped (going the full range and decrementing a degree per side i.e. 67 to 107, 68 to 106, 69 to 105...
I just tried the following and it did some weird things. Definitely not what I was thinking it'd do (work from the outside bounds (67 and 107 in my case) and gradually get smaller as the numbers head...
I think that makes sense to me. I'll try it. What if I want to offset it by say + or - 10 with a maximum still capping at 180?
Don't bet your life on it! I'm a beginner when it comes to programming:)
but is it a set of brackets missing for the first "for" loop to encapsulate the second?
Thanks for the input and cool username:) lol
As far as the motor it is a DC Servo. I have it working with the above code that I'd posted (taken from a library for this microcontroller) but would...