Does code::blocks detect infinite loops? Because that's what you've got there.
for (i=1; i<num; i+=.1){
j=j*i;
}
Type: Posts; User: bivhitscar
Does code::blocks detect infinite loops? Because that's what you've got there.
for (i=1; i<num; i+=.1){
j=j*i;
}
Try %.8f ;)
By default, %f only prints to 6 decimal places.
The main problem is the logic, not specific values. I think you can work it out though, just read the code and modify small things to see how they effect the whole system. If we give you all the...
Well, P2OUT and P2DIR are different statements. Either way, the OP has a fairly considerable problem with the logic in the transmitter.
Pretty sure that's the buzzer.
I agree with tabstop, I'm pretty sure the problem is in the transmitter side.
Yeah, I worked that out a bit later.
Did you try my code from post #29?
Jannr, read common's code - you must initialise both max and min. If you don't initialise a variable before you use it, the behaviour will be undefined.
What happens if someone enters in all positive integers? ;)
[EDIT]
The second half of your statement is spot on though.
[EDITEDIT]
...or all negative integers.
One of the obvious issues is that you haven't initialised min and max before using them in a comparison.
if(a<min) //what is the value of min at this point?
Is all this code in one file...?
Can you try replacing all the code in here:
if(packet.frame[9]=='A')
{
}
With this:
Can you explain what you mean by this? Does it rapidly flash 10, then 20, then 30 (or 30, then 20, then 10)?
The only way this is possible, is if the transmitter isn't sending the expected...
At a guess, you need to post code. A second guess would be that as you are using cout, you should be posting that code in the C++ forum. :)
Ok, if you get 1 LED for 10cm and 2 LEDs for 20cm - then we know the transmitter is sending the correct signal.
This is just a guess but try deleting the following line from both the W and A if...
So I guess when 20cm is reached, two LEDs turn on and still nothing in the 7seg? Do you get anything in the 7seg at all, or completely blank?
So when the water level reaches 10cm, what happens? Don't worry about anything else for now, just start with this question.
No, even in the land of microntrollers, mod is mod and divide is divide. I just think the code we're seeing is a simplified version of a future, more complex, version.
[EDIT]
...and our OPs...
I agree with everything quzah is saying - though this is what I was referring to earlier. I was assuming that 20%10 would become 20%var. I was also assuming that you might think to create a function...
Could you paste the code where you try to make 10 and 20 work?
If you wrote the code that is in your original post, then you shouldn't have any trouble making the two 7-segs display 20 for W and 10 for A.
Nah, looks to me like it's just initialising a receiver then reading off whatever it gets sent:
void MRFI_RxCompleteISR()
{
mrfiPacket_t packet;
MRFI_Receive(&packet);
...
Given that this is a microcontroller, it's pretty common to declare the return type as void - because if your main ever actually returns you've made a mistake and there's no one there listening.
While I have limited micro controller experience and my C is rusty (just getting back into the swing) - I think you'll find you need to analyse the code within the following block to find the answer:...
How could you do it without arithmetic operators; surely that's impossible?
Or are you meant to use bit-fiddling techniques?