Recent Posts

Pages: [1] 2 3 ... 10
1
Project Guidance / Re: How does byte code work?
Last post by Sharkbyte1 - Today at 03:07 am
Well, that's why I'm asking. I'm a novice when it comes to arduino.
2
Programming Questions / Re: if() question
Last post by vaj4088 - Today at 03:06 am
RayLivingston wrote (in part):

Quote
...a signed 24-bit binary fraction representing values between 0 and LSB less than 1.0 ...
Sorry, but I believe that IEEE-754 uses a hidden bit and has a mantissa in the range [1, 2).  I probably should have suggested using an int, but a float of 1.0 should also work.

Delta_G wrote (in part):

Quote
Well in binary 1/10 has the same problem.
Uh, no.  1/3 is a repeating decimal.  1/10 and 1/100 are not repeating decimals .  1/10 is a repeating binary.  1/100 does not show an obvious repeat to me in the first 32 binary digits but I am willing to learn.
3
Project Guidance / Re: How does byte code work?
Last post by INTP - Today at 03:03 am
https://www.arduino.cc/en/Reference/HomePage

Look under data types.

Stop making assumptions. Thinking you know things is only making obstacles for yourself to unknow and learn.
4
Project Guidance / Re: How does byte code work?
Last post by Sharkbyte1 - Today at 02:58 am
Ooh, could you elaborate? Byte data is referring to binary right?
5
Generale / Re: Misuratore Ampere / Volt /...
Last post by ricki158 - Today at 02:49 am
Quindi da applicare al negativo della pista, così da poter "tornare indietro" ad ogni pista. Chissà se può andare ad influire sul comportamento delle macchine.

Intanto comincio ordinando una Mega e tirando qualche cavo fino alla postazione della direzione gara.

Come schermo OLED sufficientemente grande cosa posso usare? Non ne ho mai usati e non so cosa offre internet.
6
Project Guidance / Re: Looking for mount board fo...
Last post by INTP - Today at 02:48 am
He's looking for a piece of wood. Literally.
7
Project Guidance / Re: How does byte code work?
Last post by INTP - Today at 02:46 am
That's not byte code. That's just a multidimensional array using the byte data type.
8
Project Guidance / How does byte code work?
Last post by Sharkbyte1 - Today at 02:41 am
Hey, I was working on an LED matrix and I came across a code that looked like this. https://github.com/pchretien/flash_leds/blob/master/flash_leds.pde

I'm unfamiliar with byte codes so can anybody tell me what the code is doing/the byte code is about?
9
Yes, there is an easier way.

Yes, this unnecessarily wastes the power of an Arduino for 10 seconds:

Code: [Select]

delay (10000);                //waits before next random number to give time for beeps


Even a newbie should know how to post correctly:

To post code and/or error messages:

1) Use CTRL-T in the Arduino IDE to autoformat your complete code.
2) Paste the complete autoformatted code between code tags (the </> button)
     so that we can easily see and deal with your code.
3) Paste the complete error message between code tags (the </> button)
     so that we can easily see and deal with your messages.

4) If you already posted without code tags, you may add the code tags by
     editing your post.
  Do not change your existing posts in any other way.
     You may make additional posts as needed.
5) Please provide links to any libraries that are used
     (look for statements in your code that look like #include ).  Many libraries
     are named the same but have different contents.

Before posting again, you should read the three locked topics at the top of the Programming Questions forum, and any links to which these posts point.

If your project involves wiring, please provide a schematic and/or a wiring diagram and/or a clear photograph of the wiring.

Good Luck!



10
Code: [Select]
        for(pos= closed_pos; pos <= open_pos; pos++){  // Open the blast gate
              my_servo[k].write(pos); //comment 1
              delay(5);
              }
           // Serial.print(k);
      }
      else{
        for(pos= open_pos; pos >= closed_pos; pos--){  // Close all other Gates
           my_servo[k].write(open_pos); //comment 2
           delay(5);


comment 1 - here you move the servo in roughly 160 steps with 5 ms delay just to open it

comment 2 - here you do the 160 steps again, but you write the open_pos to servo 160 times.

In setup, you spent 25 ms opening all 5 blast gates, here you spend almost a second per gate blocking everything else.

Why?
comment 1 I based this on the example sketch where they used a for loop to sweep a servo.  if there is a better way I'm open to it.  I thought about just setting the open or closed position value in a single write command.

comment 2 That was a typo when I was trying different inputs while debugging the section of the code has been updated.

Code: [Select]

// This section waits until on of the pins goes to LOW
while(digitalRead(switch_pin[0]) == HIGH && digitalRead(switch_pin[1]) == HIGH
      && digitalRead(switch_pin[2]) == HIGH && digitalRead(switch_pin[3]) == HIGH
      && digitalRead(switch_pin[4]) == HIGH) {
      }   //  Waiting loop for input from the switch while all switchs high              
    

   // This section loops through all 5 gates  
   for(int k = 0;k<5;k++){    // read pin state if low then open that gate else close all others
       switch_state[k] = digitalRead(switch_pin[k]);  //stores the switch state in an array
      if(switch_state[k] == LOW && millis() - time > debounce){  
    //if switch state is low then open the gate
         for(pos= closed_pos; pos <= open_pos; pos++){  // Open the blast gate
              my_servo[k].write(pos);
              delay(5);
              }
           // Serial.print(k);
      }
      else{
        for(pos= open_pos; pos >= closed_pos; pos--){  // Close all other Gates
           my_servo[k].write(pos);  // There was a typo here should have been written this way for the loop to work
           delay(5);
           }
      //  Serial.print(k);
      }
      
   }  // End for loop checking the state of the switches


The set up section is just to set the initial state I have no idea if the controller has the ability to store the previous state after a power down, if it can I would rather have that than reopen all the gates.  The way I have it the initial state is known.  
Pages: [1] 2 3 ... 10