Show Posts
|
|
Pages: 1 ... 5 6 [7] 8 9 ... 13
|
|
92
|
Using Arduino / Programming Questions / Re: A simple question I am sure
|
on: November 29, 2012, 12:29:32 am
|
I am a humble chemist after all
I'm just a poor science teacher, please don't just tell me I'm wrong and not tell me a solution
Now you're just being mean.
I don't understand your advice in reply 9.
I don't understand what to call the variables, how to summon them and get them to do anything, is it something to do with sacrificing chickens?
'm sorry.
I spent several hours, that feel like days, banging my head.
I think I have found a route, but it seems different from what you suggested.
It's mean your are looking here for some one who will serve you meal(code)  .
|
|
|
|
|
93
|
Using Arduino / Programming Questions / Re: How to use Timer to exit LoopA,then run LoopB?
|
on: November 29, 2012, 12:03:54 am
|
PaulS says: @Cybernetician What is going to happen after the Arduino has been running for 10 seconds in your code?
Aqualize Says: Yes that one only works the first iteration. I haven't compiled this code to test (to the Arduino C++ variant have do...while... loops?). long quitTime; void loop () { quitTime = millis () + 10000; do { // Do stuff } while (millis () < quitTime);
quitTime = millis () + 2000; do { // Do other stuff } while (millis() < quitTime); }
Remember that it won't interrupt the execution and jump out of a loop, so to make it work you can't have too much code (execution time wise "much") in there. Say that in the second step you have code which takes 1.5 second to run. Then it will exit the loop 3 seconds after it started. But if you have code that only takes 10 ms to run, well you may overshoot with a few ms but that is probably okay. @Cybernetician What is going to happen after the Arduino has been running for 10 seconds in your code? void loop(){ while (millis() < 10000) { LoopA(); } while (millis() < 2000) { LoopB(); } } Ooops. what a big mistake tomorrow i post right one now i am late thanks PaulS. Need to minus time of loopA, loopB, and other statements execution time for near to perfect result. #include "Timer.h"
Timer t;
bool lpA = true; bool lpB = false; int loopAEvent; int loopBEvent;
void setup() { Serial.begin(9600); loopAEvent = t.every(10000, loopBFlag); }
void loop() { t.update(); if(lpA==true) { Serial.println("LOOPA"); } if(lpB==true) { Serial.println("LOOPB"); } }
void loopBFlag() { t.stop(loopAEvent); lpA=false; lpB=true; loopBEvent = t.every(2000, loopAFlag); } void loopAFlag() { t.stop(loopBEvent); lpA=true; lpB=false; loopAEvent = t.every(10000, loopBFlag); }
|
|
|
|
|
98
|
Using Arduino / Programming Questions / Re: IR Sensors Read, Compare, and Output Code?
|
on: November 27, 2012, 11:57:11 pm
|
First i haven't experience of something like that but i try my best to help you. The issues we are having is that the output is constantly being turned on and it should only be on if any of the two front wheels are spinning less than the rear. In other words, if the input from FRS is a higher average than FLS, the pin should be on. Lets start troubleshooting post the values of ReadFRS ReadFLS ReadRS FrontAverage . . .
by using Serial. Serial.prinln(ReadFRS); Serial.prinln(ReadFLS); Serial.prinln(ReadRS); Serial.prinln(FrontAverage); Serial.prinln(FrontCompare); Serial.prinln(TotalCompare);
|
|
|
|
|
101
|
Using Arduino / Programming Questions / Re: Help with Sketch
|
on: November 27, 2012, 11:28:30 pm
|
if (val >= 1 && val <= 100) digitalWrite(aPin, HIGH); digitalWrite(bPin, HIGH); digitalWrite(cPin, HIGH); digitalWrite(dPin, HIGH); digitalWrite(ePin, HIGH); digitalWrite(fPin, HIGH); digitalWrite(gPin, LOW);
again wrong attemp first read comments and apply them. 
|
|
|
|
|
102
|
Using Arduino / Programming Questions / Re: IR Sensors Read, Compare, and Output Code?
|
on: November 27, 2012, 11:26:11 pm
|
... Now, I know my code probably has plenty of flaws and I am totally open to suggestions and I should probably be using some sort of frequency reading and comparing but I do not know how to use PulseIn() properly or any other frequency detection code. Again, this is my first time using this.
Our final submission is tomorrow so I do not have a lot of time and this is my last resort before saying "screw it".
will you explain what hurdle you facing and Is it not working?
|
|
|
|
|
103
|
Using Arduino / Programming Questions / Re: Help with Sketch
|
on: November 27, 2012, 11:23:53 pm
|
if (val >= 1 && val <= 100); digitalWrite(aPin, LOW); digitalWrite(bPin, LOW); digitalWrite(cPin, LOW); digitalWrite(dPin, LOW); digitalWrite(ePin, LOW); digitalWrite(fPin, LOW); } {
If you want to do action on val >= 1 && val <= 100 if (val >= 1 && val <= 100) { digitalWrite(aPin, LOW); digitalWrite(bPin, LOW); digitalWrite(cPin, LOW); digitalWrite(dPin, LOW); digitalWrite(ePin, LOW); digitalWrite(fPin, LOW); }
|
|
|
|
|
104
|
Using Arduino / Programming Questions / Re: Help with Sketch
|
on: November 27, 2012, 11:21:46 pm
|
if (val >= 1 && val <= 100); digitalWrite(aPin, LOW); digitalWrite(bPin, LOW); digitalWrite(cPin, LOW); digitalWrite(dPin, LOW); digitalWrite(ePin, LOW); digitalWrite(fPin, LOW); } {
Search for how to use of IF statement
|
|
|
|
|