Arduino Uno Programming Assistance Request

Advert

Arduino Uno Programming Assistance Request

Home Forums Electronics in the Workshop Arduino Uno Programming Assistance Request

Viewing 11 posts - 76 through 86 (of 86 total)
  • Author
    Posts
  • #337849
    Marcus Bowman
    Participant
      @marcusbowman28936

      I have just noticed the 'smileys' the site has added to the sketch. Wasn't me: honest.

      If someone can tell me how to upload a sketch as an attachment, I can do that later tonight. If not; the smileys need to be edited out.

      Marcus

       

      Edited By Marcus Bowman on 22/01/2018 19:13:33

      Advert
      #337868
      SillyOldDuffer
      Moderator
        @sillyoldduffer

        Those smileys – don't cha luv 'em? LOL

        The site converts character smiley sequences into imojis. The sequence that causes most trouble in posts containing C source is a right bracket ) followed immediately by a semi-colon;

        The site won't do an imoji if you type a space character between the ) and the ;

        There's a better way. Retaining indentation when publishing source code is also a problem. It can be done by fooling the site by embedding your own HTML tags in the text. The ordinary 'Post a reply' window blocks this but the edit function doesn't

        The method I use is to first type and save the post without inserting the source code. Then immediately edit the post to insert html tags <code> and </code> on separate lines where you want your source to appear. Finally paste the source between the html tags and save the edit.

        Bit of a fiddle but all being well any text inserted between the tags should appear in a fixed font with indentation. As the length of posts is limited keep it short.

        Dave

        #337869
        Frances IoM
        Participant
          @francesiom58905

          That ‘feature’ in edit seems worrying unless it is severely restrictive – if it accepts iframes + cross site links or javascript then all bets are off as to what can be done

          #337879
          James Alford
          Participant
            @jamesalford67616

            Dave:

            I had noticed that the SDA and SCL pins were labelled on the board, but did not know whether they still needed to be referenced.

            I have also been coming around to the idea of starting the basic RTC code again to get that working and then reintroducing the additional structure, stage by stage. I shall try this over the next few days. Thank you for the offer of looking at my coding, should I get nowhere. I appreciate this, but shall try to resolve it myself before taking up more of your time.

            I had thought that I used a RTC library from Northern Widget on github, but I am no longer quite sure. What puzzles me further is that I went back to the place where I initial found the RTC code that I am using and there is no reference there to any RTC library. The trouble is that I did this bit of coding several months ago and have forgotten the detail. A good example of why I should have added more notes to the source in the code……..

            Marcus:

            Thank you for the RTC code. I shall copy this over and try it out to see whether I can then use this to get me going again.

            Watch this space for an update in a day or two's time.

            Regards,

            James.

            Edited By James Alford on 23/01/2018 07:08:50

            Edited By James Alford on 23/01/2018 07:09:19

            Edited By James Alford on 23/01/2018 07:10:02

            #337957
            James Alford
            Participant
              @jamesalford67616

              Good evening.

              I am utterly bemused. This morning, I created a new sketch using the code that Marcus posted above, editing it to remove the smiley faces. I installed the relevant library and uploaded the programme to the board to test it: all went well and it worked, printing to the serial printer as designed.

              This evening, out of curiosity, I tried compiling my original code again, having made no alterations to it. Much to my surprise, it compiled, loaded and ran perfectly.

              I have absolutely no idea at all why this should have happened. The only thing that I can think of is that, somehow, installing the library for Marcus's code allowed mine to work. As the library names are different, this seems unlikely, but I really can not see what else it can be. No matter what; I shall be wary about further board and library updates.

              I should just like to thank you all again for the detailed help with this problem.

              Regards,

              James.

              #337972
              doubletop
              Participant
                @doubletop

                Configuration management. You do it on physical engineering projects but can be so much harder in the virtual world when you can’t see the detail

                Suddenly all your imperial nuts become metric and things assemble properly

                Pete

                Edited By Doubletop on 23/01/2018 22:50:44

                #338017
                SillyOldDuffer
                Moderator
                  @sillyoldduffer

                  Posted by Doubletop on 23/01/2018 22:48:38:
                  Configuration management.

                   

                  Agreed. The Arduino IDE hides the gory details in the interest of keeping the programmer's life easy. When you use a library, or #include a header, the compiler searches through certain folders for a match. The search order appears to vary. If you install more than one library for a device there's a possibility your sketch will find the wrong one. The problem can also effect libraries; if they depend on another library, they too can link to the wrong one.

                  Quite often modules like the RTC are supported by several libraries offered on the web by different people. It's common to try a few to find one that works, which can leave your computer littered with unwanted libraries. It's good practice to delete them.

                  Dave

                  Edited By SillyOldDuffer on 24/01/2018 10:13:54

                  #338695
                  James Alford
                  Participant
                    @jamesalford67616

                    Good afternoon.

                    I wonder whether anyone can advise before I go on a wild goose chase?

                    I have added another sequence of code to activate an additional pin once an hour. As I have run out of digital pins, I have used the analogue pin A3. I have copied and amended a block of code that I have already used to carry out the same function on a digital pin. It uses Dave's "tpulse" function to trigger the pin to light an LED.

                    The timing sequences all work correctly, but the LED does not light. As a test, I replaced the "tpulse" lines used to trigger the output with a simple delay. This lit the LED correctly at the appropriate intervals, confirming that the timing sequence and the circuitry are correct.

                    Before I go chasing the problem, does anyone know whether the "tpulse" function will actually work with an analogue pin? I have a niggling suspicion that it will not, but I am not quite sure why. Any help would be appreciated.

                    Thank you.

                    James.

                    Edited By James Alford on 28/01/2018 15:00:18

                    #338705
                    SillyOldDuffer
                    Moderator
                      @sillyoldduffer
                      Posted by James Alford on 28/01/2018 14:59:29:

                      Good afternoon.

                      I wonder whether anyone can advise before I go on a wild goose chase?

                      I have added another sequence of code to activate an additional pin once an hour. As I have run out of digital pins, I have used the analogue pin A3. I have copied and amended a block of code that I have already used to carry out the same function on a digital pin. It uses Dave's "tpulse" function to trigger the pin to light an LED.

                      The timing sequences all work correctly, but the LED does not light. As a test, I replaced the "tpulse" lines used to trigger the output with a simple delay. This lit the LED correctly at the appropriate intervals, confirming that the timing sequence and the circuitry are correct.

                      Before I go chasing the problem, does anyone know whether the "tpulse" function will actually work with an analogue pin? I have a niggling suspicion that it will not, but I am not quite sure why. Any help would be appreciated.

                      Thank you.

                      James.

                      Edited By James Alford on 28/01/2018 15:00:18

                      It should do; the analogue pins are digital pins plus an analogue to digital converter. If you treat them as digital pins they should just work. e.g set them to OUTPUT or INPUT with pinMode. e.g pinMode( A0, OUTPUT ); then digitalWrite( A0, HIGH ); should do its stuff.

                      Do you have a multimeter or even better an oscilloscope? Easier to see what's going on – you may have a dud LED, resistor, or lead, or have the LED the wrong way round.

                      I'm about to start an Arduino session: won't take long to give pulse() a try and let you know.

                      Dave

                      #338711
                      SillyOldDuffer
                      Moderator
                        @sillyoldduffer

                        Tried it and pulse() works fine with A0.

                        #include <Event.h>
                        #include <Timer.h>

                        Timer t;

                        void setup() {
                        pinMode( A0, OUTPUT );
                        t.pulse(A0, 100, LOW); // 100mS start and end LOW
                        }

                        void loop()
                        {
                        t.update();
                        analogRead( A1 ); // Prove doing an analogRead doesn't disable anything.
                        }

                        Just a thought as I got confused trying this: pulse only sends one pulse and the start HIGH/LOW parameter makes a difference. So t.pulse(A0, 100, HIGH) goes high and stays high. t.pulse(A0, 100, LOW) starts LOW, goes HIGH, and finishes LOW.

                        For proving that the pin is OK it might be better to test it with pulse.oscillate( A0, 500, HIGH ). That will cause the pin to flash continually which is easier to see is working properly.

                        Dave

                        #338718
                        James Alford
                        Participant
                          @jamesalford67616

                          Dave,

                          Thank you for checking and confirming that it is possible to use t.pulse with an analogue pin. I have had another look at my code and found the problem.

                          I have a variable that is used to determine whether or not the hour LED should trigger. I copied the code used to trigger the LED on pin 11 each hour and renamed the variables to activate a different LED on pin A3. However, I missed one variable.

                          Once the hour LED has flashed, this variable prevents it from flashing again until the next hour. As the new sequence is after the hour sequence, the new code was being told not to run by this variable. Renaming it for the second routine solved it and it now functions as planned.

                          Regards,

                          James.

                           

                          Edited By James Alford on 28/01/2018 17:33:47

                        Viewing 11 posts - 76 through 86 (of 86 total)
                        • Please log in to reply to this topic. Registering is free and easy using the links on the menu at the top of this page.

                        Advert

                        Latest Replies

                        Viewing 25 topics - 1 through 25 (of 25 total)
                        Viewing 25 topics - 1 through 25 (of 25 total)

                        View full reply list.

                        Advert

                        Newsletter Sign-up