[Dprglist] Arduino Code Troubles

Karim Virani pondersome64 at gmail.com
Thu Dec 16 17:44:58 PST 2021


It's doing what it's coded to do

On Thu, Dec 16, 2021 at 7:42 PM Pat Caron via DPRGlist <
dprglist at lists.dprg.org> wrote:

> Hi Murray, I did try that with the same results.  NewPing.h library is
> looking for a uint16_t although it didn't complain when I tried that.
>
> ...Pat C
>
> On Thu, Dec 16, 2021 at 8:35 PM Murray Altheim via DPRGlist <
> dprglist at lists.dprg.org> wrote:
>
>> Hi Pat,
>>
>> What if you define maxDistance as uint32_t?
>>
>> Cheers,
>>
>> Murray
>>
>> On 17/12/21 2:27 pm, Pat Caron via DPRGlist wrote:
>> > Hi guys, I'm looking for help with the following Arduino code.
>> >
>> >      uint32_t cm[8] = {0,0,0,0,0,0,0,0}; // Create array
>> >      uint16_t maxDistance = 200; // Also used with NewPing.h library
>> >      .
>> >      . // Other code here
>> >      .
>> >      irSensorL.read(); // Read IR sensor... This is working!
>> >      cm[3] = irSensorL.ranging_data.range_mm/10; // This returns 268
>> >      if (cm[3] > maxDistance) {
>> >        cm[3] = 999;                 /
>> >      }
>> >      Serial.println(cm[3]);  / cm[3] value is always = 999
>> >      sendData();
>> >
>> > The cm[3] value is always 999 when I run this.
>> > If I comment out the if cm[3]... statement cm[3] value is then 268.
>> >
>> > ...Pat C
>> >
>> > _______________________________________________
>> > DPRGlist mailing list
>> > DPRGlist at lists.dprg.org
>> > http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org
>> >
>>
>> --
>>
>>
>> ...........................................................................
>> Murray Altheim <murray18 at altheim dot com>                       = =
>> ===
>> http://www.altheim.com/murray/                                     ===
>> ===
>>                                                                     = =
>> ===
>>      In the evening
>>      The rice leaves in the garden
>>      Rustle in the autumn wind
>>      That blows through my reed hut.
>>             -- Minamoto no Tsunenobu
>>
>> _______________________________________________
>> DPRGlist mailing list
>> DPRGlist at lists.dprg.org
>> http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org
>>
> _______________________________________________
> DPRGlist mailing list
> DPRGlist at lists.dprg.org
> http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dprg.org/pipermail/dprglist-dprg.org/attachments/20211216/e11f52d3/attachment.html>


More information about the DPRGlist mailing list