Show Posts
Pages: [1] 2 3 ... 8
1  Using Arduino / Programming Questions / Re: Stumped again Blinky on: January 02, 2013, 12:10:00 pm
I thought this was snipits.com lol too funny.
A state machine is probably the only answer here;  hopefully since what I want do is so simple, I can figure out how to build one.
Scarey stuff for a newb.

2  Using Arduino / Programming Questions / Stumped again Blinky on: January 02, 2013, 09:40:44 am
I'm near the end of my program and I'm stumped this is what I need
1) checks if its 12 hours into the program
then sets up a while loop
2) In the while loop it has 2 blinky's, one that blinks every 12 hours on off, and one that blinks for 20 seconds on off every 24 hours.
3) Then in 14 days, it breaks out of the loop and the whole program starts over.

I got the 1st Blinky, to turn on off every 12 hours, and only when its 12 hours into the program too. The second Blinky, shouldn't be too hard set up, using a for loop counter every second blink, some thing like that.
They don't have to be very accurate.

Lost how to to do this any hints would be appreciated.
Thanks
Code:
}
//Light and Topup
  digitalWrite(7, LOW);  //Nutrient Heater on
  if (StartTime >= hours_in_ms(12)){
    while(y){
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;
    digitalWrite(ledPin, ledState);
}

 
3  Using Arduino / Programming Questions / Re: lil help please on: January 01, 2013, 05:57:39 pm
"Looks to me your code will work just once after a powerup or a board reset. Is this what you want ?"
Actually yes and no, nice catch. (this is just a test more to come)
Its going to do a bunch of stuff 14 days, then start over at the end of the main loop (perfect) or start over on a power up or board reset...so yes
but no...Id prefer it to pickup where it left off, on lets say a power outage. Code wise that's too hard to do, so battery backup is prob the answer.
unless you got other ideas.

Haven't tried it yet I will tomorrow

4  Using Arduino / Programming Questions / Re: lil help please on: January 01, 2013, 04:20:11 pm
OK I think I got it yay.. here's what I did.
pin 5,6,7 come on same time
5 runs 3min.
6 runs 7min.
7 runs 9 min.
then it breaks out of the loop and
turns pin 4 on and the whole loops and starts over.
This is not exactly what I want, but it is the Idea for what I'm trying to do.
Hope its right




Code:
#define seconds_in_ms(s) ((s)*1000UL)
#define minutes_in_ms(m) ((m)*60UL*1000UL)
#define hours_in_ms(h)   ((h)*60UL*60UL*1000UL)
#define days_in_ms(d)    ((d)*24UL*60UL*60UL*1000UL)
#define weeks_in_ms(w)   ((w)*7UL*24UL*60UL*60UL*1000UL)

boolean x = true;

void setup() {
   
   
   pinMode(2, OUTPUT);   
   pinMode(3, OUTPUT); 
   pinMode(4, OUTPUT); 
   pinMode(5, OUTPUT);
   pinMode(6, OUTPUT);   
   pinMode(7, OUTPUT); 

  digitalWrite(2, LOW);   
  digitalWrite(3, LOW); 
  digitalWrite(4, LOW); 
  digitalWrite(5, LOW); 
  digitalWrite(6, LOW); 
  digitalWrite(7, LOW); 
 
 
}
void loop ()
{
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  unsigned long Task1Time = millis();
  while(x){
 
  if (Task1Time >= minutes_in_ms(3)){
   digitalWrite(5, LOW);
   
}
  if (Task1Time >= minutes_in_ms(7)){
     digitalWrite(6, LOW);
}
  if (Task1Time >= minutes_in_ms(9)){
     digitalWrite(7, LOW);
      x = false;
}
}
  digitalWrite(4, HIGH); //not really but a whole bunch other code goes here before it all loops
 
}

5  Using Arduino / Programming Questions / Re: lil help please on: January 01, 2013, 01:19:18 pm
your right "By the time this code gets executed, millis() will return a non-negative, non-zero value. Therefore this will ALWAYS be true. Seems silly to test an expression that can not possibly be false."
I want it to always be true, as I want them all to start the same time, real dumb I should of said just start no expression.
Loop within a loop is stupid, maybe, but what if you want to run some more code after this loop is finished, its going to fire 4 relays then do other stuff after they all finish.
The while(x = false) was my way out of the loop after my 4 relays were finished.
Why are you assigning false to x in the expression? == is the equality test operator, not =
Not sure what you mean, I guess it should be while(x) or while(x==true) some thing like that
got to go to work now I will think about this some more try again later thanks
6  Using Arduino / Programming Questions / lil help please on: January 01, 2013, 12:27:29 pm
If trying to write a little code,  lets call them Leds, actually they are relays. They all start same time
run for a bit but end at different times.
I think I can do it in a while loop, this gives me a Void loop': and a expected } error

Code:
void loop (){
boolean x = false;
while(x = false)
{
 
 unsigned long Task1Time = millis();
  if (Task1Time >= 0){
   digitalWrite(5, HIGH);
  }
   if (Task1Time >= minutes_in_ms(5)){
   digitalWrite(5, LOW);

}
}
7  Development / Other Software Development / Re: SCoop - multitask and Simple COOPerative scheduler AVR & ARM on: December 23, 2012, 05:09:11 pm
Wow this looks promising,
Multitasking is why I left arduino, for other platforms that had integrated stable multitasking.
As you know C does not provide for multitasking, so you need to have things like Free RTOS which has compatibly issues with arduino, so thus the DuinOS was born. These are not solutions or even a good patch in my opinion, DuinOS is in Alfa and has little support. Free RTOS is like learning a new programing language, confusing and provides no real support for the 1st time user.This whole Idea of get this alfa, and download patch this and that, and maybe it will work, if you can figure it out, and doesn't crash on you is stupid. Occam-pi is another way to get multitasking out of your arduino but it's a totally new programing language with little support. In many ways I think Occam is far better programing environment then C or even RTOS at least when you learn to use it, its easy to move on to the multitasking. I sure hope you guys can work this out, but its never going to work if its not simple and fully integrated, something that I don't see happening soon.

8  Using Arduino / General Electronics / Re: Simple backup power on: December 20, 2012, 05:10:37 pm
Oh ya, then if you wanted to start it at the beginning instead of at your saved point wow more complicated stuff.
9  Using Arduino / General Electronics / Re: Simple backup power on: December 20, 2012, 05:06:44 pm
Well I guess the settings I'm referring to, is the program runs various things 14 plus days, depending on how long some things take. Then the whole thing loops and starts over.I suppose I can store it at what point it was at, in eprom then on startup it can start at that point,  but that sure sounds super complicated.
10  Using Arduino / General Electronics / Simple backup power on: December 20, 2012, 03:42:51 pm
I was wondering if any of you guys have any simple back up power ideas
I don't like loosing all my settings when the power goes out, I was thinking like a 9v battery.
Guess I need diodes so it it wont get over charged, maybe there is a kit I don't know about.
Thanks
11  Using Arduino / General Electronics / Re: A simple wire question (FTDI) on: December 18, 2012, 07:53:05 am
Thanks
Just what I was looking for, but $5 for 4 wires I think Ill get the 100 pack pins make my own now I know what to get.
12  Using Arduino / General Electronics / A simple wire question (FTDI) on: December 17, 2012, 09:37:30 pm
Ok I have an FTDI board,what wire do I use?.
Sounds crazy but I'm looking for something a little more permanent that wont just fall out like a wire can.
it has headers like an arduino any Ideas?.
Thanks
13  Using Arduino / Microcontrollers / Re: New kid on the block on: November 25, 2012, 12:46:04 am
"I can get a Raspberry PI", you sure can, but you wont be any better off, can you run C# or visual basic, well the answer is no.
You can run a version of C, actually, its  been so hard to do things with that, they are trying to port arduino to it.
so good luck with that PI
14  Using Arduino / Microcontrollers / Re: New kid on the block on: November 24, 2012, 09:46:44 pm
"Unless you can dumb it down to a point where people can use it without reading a 1000+ page datasheet"
Not sure where these misconceptions come from, the beginners guide is the same size as the arduino one.
The real time debugging makes it super easy to find problems, also with most programers using Visual studio there's far more help out there then even arduino. Its true that they don't have all the community that's been built around the arduino but its growing. The software is actually much easier to use then the arduino you don't need to build complicated state machines or timers to get basic programs working or add computers because of no built in multitasking. The hardware is not the only problem I see, but also a programing environment that's old and almost obsolete.





15  Using Arduino / Microcontrollers / Re: New kid on the block on: November 24, 2012, 08:43:25 pm
"the tremendous popularity and sales volume for the arduino?"
Well the arduino has been around for some time and has built up a strong following, but that doesn't necessarily mean its the easiest to use for beginners or even the best system for them. I'm sure a PIC fanboy would disagree with you, but I do think if the product needs reform to stay current.
You cant just keep telling people a horse and buggy is good enough soon the cars will run you off the road.
Pages: [1] 2 3 ... 8