#help-with-arduino

1 messages · Page 103 of 1

north stream
#

You could do it by (ab)using preprocessor macros, I suppose

livid osprey
#

Something like this?

#ifndef LED_BUILTIN
  #define LED_BUILTIN PIN_LED
#endif
north stream
#

That should catch that case, but might fail if PIN_LED also isn't defined

dim field
#

Does anybody here have experience with SSD1306 OLED displays? I'm trying one out for the first time with the Adafruit Arduino library, and the ssd1306_128x32_i2c example sketch, but I'm getting absolutely no signs of life on the display. I'm running this on a Teensy 2.0 at 5V/16MHz, and I've run an I2C address scanner sketch, which DID find the device at address 0x3C, but the display is completely blank. So basically, I'm at that awkward stage of debugging where I kind of have no feedback from the device and nothing else to go on.

#

This is the exact display I'm using. 4 pin, sold and marked on the PCB as I2C, not SPI (and the fact that the I2C address scanner finds it seems to support that as well). No reset pin, but it does appear to have a power-on-reset circuit.

https://www.ebay.com/itm/254586028170

#

I've also confirmed that it does have a 3V regulator on-board, FWIW

vivid rock
#

there are several different chipsets that are used in such oled displays: SSD1306, SSD1315, SH1106, which are not quite compatible, and the vendors are usually sloppy in marking them

livid osprey
#

Oh right, those guys. That's always a rough one to identify; I remember playing with the initializers so much just to try to get it to work right, only to realize I was dealing with the wrong chipset.

#

@vivid rock How did you get those SH1106 displays working with SSD1306 software in the first place, anyways?

vivid rock
#

by praying

#

seriously, i dont know. They kinda worked, but half the screen was garbage

gilded gazelle
#

having trouble getting i2c out of the 8266-s3
`#include "Wire.h"

void setup(){
Serial.begin(115200);
while(!Serial){} // Waiting for serial connection

Serial.println();
Serial.println("Start I2C scanner ...");
Serial.print("\r\n");
byte count = 0;

Wire.begin(4,5);
for (byte i = 8; i < 120; i++)
{
Wire.beginTransmission(i);
if (Wire.endTransmission() == 0)
{
Serial.print("Found I2C Device: ");
Serial.print(" (0x");
Serial.print(i, HEX);
Serial.println(")");
count++;
delay(1);
}
}
Serial.print("\r\n");
Serial.println("Finish I2C scanner");
Serial.print("Found ");
Serial.print(count, HEX);
Serial.println(" Device(s).");
}

void loop() {}
`

#

hmm I tried to mark as code

#

` not ' ooppps

#

sorry

#

regardless of the pins in Wire.begin() I find no devices

leaden walrus
#

just fyi - you can edit previous message to fix code markup

gilded gazelle
#

thanks

gilded gazelle
cedar mountain
gilded gazelle
#

device is si7021, no resistors

cedar mountain
#

That's likely the issue. I2C won't work without pullups. You would want a value between about 2.2k and 10k on both SDA and SCL.

gilded gazelle
#

since I dont have pull ups, I guess I could tick a terminator chip on the end

#

ltc4311?

#

or is that NY-LA via Sydney?

#

or just lost in the ocean

cedar mountain
#

A couple of one-cent resistors would be easier... 😅

gilded gazelle
#

I have no component supply close and dont wish to order just a couple xistors

#

resistors

cedar mountain
#

If I were you I'd just get a resistor kit, containing a few hundred at random values. Handy to have around if you'll be working with electronics.

gilded gazelle
#

yeah, I am a retired vacuum tube tech, used to have all that, in 1/2w and larger HAHAHA

#

would the terminator work to prove it works or still be buggy?

cedar mountain
#

Normally terminators will be like 50 ohm or something, right? That's way too much for I2C.

gilded gazelle
#

@cedar mountain, thank you for your advice

cedar mountain
#

That would help, but mainly because it includes pullup resistors on the board. Actually, I should have asked before... Is your Si7021 an Adafruit board? If so it would probably have pullups on it already.

livid osprey
#

What boards are you using?

#

Oh, that module. Try using the hardware I2C pins instead. From the datasheet, it would be IO14 for SCL and IO2 for SDA.

#

Any other pins may require an external pullup.

pallid grail
#

@leaden walrus I have a nomenclature question when you're around. Please ping when you're available, if you would be so kind.

leaden walrus
#

@pallid grail hey. what's up.

pallid grail
#

@leaden walrus Do you refer to Arduino pin numbers as pin "names" or pin "numbers" or both? The RP2040 Arduino pins are the GPIO pins, so GPIO0 is Arduino pin 0. But I don't know whether to call 0 a pin name or number. Or either.

leaden walrus
#

hmm...i think maybe "name"

#

but either could work depending on context

pallid grail
#

Ok thank you, that's what I went with, but wasn't certain.

still zealot
#

For a project I am wanting to work with an ItsyBitsy M4 with the SAMD51. Im looking for a library that can do low power/sleep modes that work with external hardware interrupts. All the ones I can find are only compatible with SAMD21. Can anyone point me in the direction of a library that i could use?

light laurel
#

Hey

#

So

#

I have this project

#

Which uses naruto handsigns to open a solenoid lock

#

So

#

My code is done

#

For now

#

I want to add an RFID sensor for a second type of unlocking method

#

My questions:
1.how do I split my solenoid lock to work on multiple modules
2.how do I write my code if the above doesn't finish will an if work?

#

Forgot to send the transmitter module

#

But here it is

#

Yes it uses flex values and angles from a gyro meter to detect

quaint nebula
#

I have one question since I’m need to Arduino

#

Using this pic as an example. When setting up your board and bringing up a neopixel code do the pins/circuits also show up in the code?

cedar mountain
north kelp
#

And level shift if the two MCUs are running at different voltages.

#

If you are using 2 MCUs, that is.

north kelp
zinc bridge
#

What are the x1 and y1 parameters in getTextBounds() for? If I call x.setCursor(0, 0) and then x.print("Line of Text"), I expect the text's left bounds to be 0 and the top to be 0, but the TomThumb and Picopixel fonts are oddly printed out several pixels above the cursor location.

#

So you have to set the cursor, get the text bounds, calculate a new cursor position, set the cursor from that, all before you can print text where you actually want it to be.

#

That is a waste of CPU cycles and program memory.

cedar mountain
light laurel
#

@north kelp but that doesn't answer my question as a whole yes it would work but I want a kind of splitter to use two different methods with the same code will and 'if' work for two modules

light laurel
#

Can I split it with relays?

north stream
# light laurel Can I split it with relays?

It depends on what you mean by "split". I'm guessing you want to be able to control a solenoid with two different drivers. In many cases, you can just share the driver, or just hook two drivers to the same solenoid (many solenoid drivers simply pull a lead down to ground to actuate a solenoid, so hooking up more than one doesn't cause a problem). You could add isolation diodes to limit backflow, but that's not generally a problem.

finite pond
#

Hello!

light laurel
finite pond
#

Did anyone tried it? I know that is i2c, I was trying the i2c scanner with no luck

light laurel
zinc bridge
zinc bridge
zinc bridge
livid osprey
#

They still count as "new" fonts rendered from a baseline cursor, IIRC. Classic fonts would be like the Serif and Sans fonts.

livid osprey
#

Despite being included in the library, they behave like that of a custom font, and should be treated as such.

tepid shard
#

Hello, I am currently following a tutorial for an arduino stopwatch, and when I try to change my port to COM7, it only shows me COM1, and when loaded onto the board 16 rectangles show and none of the buttons do anything except the potentiometer that changes the brightness

#

I also get this error avrdude: stk500_recv(): programmer is not responding

#

if anyone could help I would be very grateful

livid osprey
#

IF you could link the tutorial you're following, that would be a good start.

tepid shard
livid osprey
#

Okay, so the potentiometer has no code so we can ignore that.

tepid shard
#

ah ye thats probably why it worked lol

livid osprey
#

Are you sure COM1 is your Arduino? Most computers reserve COM1 for a hardware serial. Open up your Device Manager on your PC and check the COM ports connected to the computer. Do the ports change when you unplug/replug the Arduino?

tepid shard
#

I am not sure tbh, there is only one port and that stays when I unplug and replug it

livid osprey
#

Then it's more likely that your Arduino isn't being detected at all by the PC. Try a different USB cable? There's a possibility that your USB cable might be charge-only...

#

Use the PC's Device Manager instead of the Arduino IDE. That one isn't always reliable.

tepid shard
#

hmm ok, just fyi I did buy a relatively cheap board without the cable (I am using the one from my proper one) so I dont have a different cable.

livid osprey
#

And the cable works with your other Arduino?

tepid shard
#

yep

#

not with the specific program

livid osprey
#

What board are you using?

tepid shard
#

an uno according to the seller

#

it was from ebay

#

ok also turns out my mic has the same cable and that has COM3 aswell as COM1

#

and if I run my cable to the usbs on the back it has COM4 (COM4 and COM1)

livid osprey
#

Well, that sounds promising. Can you try programming the Arduino with that cable?

tepid shard
#

YESSS

#

ok wait

#

I cant stop the timer

#

avrdude: stk500_recv(): programmer is not responding avrdude: stk500_recv(): programmer is not responding avr_read(): error reading address 0x0000 read operation not supported for memory "flash" avrdude: failed to read all of flash memory, rc=-2 avrdude: stk500_recv(): programmer is not responding the selected serial port avrdude: stk500_recv(): programmer is not responding does not exist or your board is not connected
this error happens

#

nvm

#

it works

#

wasnt plugged in properly 🤣

#

tysm dude 😎

#

may I ask, since I am using this for a project, would I be able to solder on some wires to the buttons and lcds and connect them to the same place on the breadboard, or does it not work like that?

livid osprey
#

Of course! If you want a nice, clean, finished feel to your completed project, you can solder everything to something like https://www.adafruit.com/product/2077, and mount it directly on top of your Arduino if it fits. Otherwise, protoboards come in all shapes and sizes, and tend to be really nice for soldering buttons and other through-hole components.

tepid shard
#

ah ok awesome, thank you!

#

I will have to check that out :)

#

also in terms of the buttons, would I solder each foot into each spot on where it should be on the breadboard?

livid osprey
#

Depends on what you're soldering to. Some protoboards are designed to match a breadboard in terms of bus connections, while others have nothing but holes that you would connect with wires or solder bridges.

tepid shard
#

so as in I solder to each of these points and put it the wires onto the places where they would be on the breadboard (without the protoboard, since I am using the soldering to add length so they fit in the holes I have cut out in my project, sorry)

livid osprey
#

If you're not using a breadboard, you just have to make sure to solder the button wires to everything else in the same breadboard row.

tepid shard
#

ah ok, thank you

livid osprey
#

In this project's case, each row only ever has one wire and one pin, so matching them up should be easy.

tepid shard
#

cool 😎

#

ty again :)

tawny owl
#

Hey! I got a Playground Bluefruit and trying to via BLE wirelessly send the built-in accelerometer values to a Windows PC to Unity3D. Does anyone know a good place to start with this?

crystal frigate
#

Hi all, I uploaded a sketch to my CLUE board and it worked fine, but now the computer will no longer find the port. What do?

pallid sage
#

I think it'll only show up during reset or somesuch?

crystal frigate
#

I did get it to work

median mica
#

I need a code review. I'm using the AccelStepper/MultiStepper library. working from the MultiStepper example. I have three steppers moving one rotation forward, delaying, then one rotation backwards. The problem is on the first run of the steppers they only move a half of a rotation, then from that point they move perfectly one rotation forward, delay, one rotation backward. the code running:

#
#include <MultiStepper.h>

const int REVOLUTIONS = 1; // number of times the wand turns
const int CYCLE = 1024;

//AccelStepper  stepper(Accelblind_1::FULL4WIRE, 0, 2, 1, 3);  // 0, 1, 2, 3 ATTiny85
AccelStepper  blind_1(AccelStepper::FULL4WIRE,  9, 11, 10, 12);  //  9, 10, 11, 12 Uno Pro Trinket
AccelStepper  blind_2(AccelStepper::FULL4WIRE, A0, A2, A1, A3);  // A0, A1, A2, A3 Uno Pro Trinket
AccelStepper  blind_3(AccelStepper::FULL4WIRE,  8,  5,  6,  4);  //  8,  6,  5,  4 Uno Pro Trinket

// Up to 10 steppers can be handled as a group by MultiStepper
MultiStepper steppers;

void setup() {
  // Configure each stepper
  blind_1.setMaxSpeed(500);
  blind_2.setMaxSpeed(500);
  blind_3.setMaxSpeed(500);

  //blind_1.setCurrentPosition(0);
  //blind_2.setCurrentPosition(0);
  //blind_3.setCurrentPosition(0);

  // Then give them to MultiStepper to manage
  steppers.addStepper(blind_1);
  steppers.addStepper(blind_2);
  steppers.addStepper(blind_3);

}

void loop() {
  long positions[3]; // Array of desired stepper positions

  positions[0] = CYCLE;
  positions[1] = CYCLE;
  positions[2] = CYCLE;
  steppers.moveTo(positions);
  steppers.runSpeedToPosition(); // Blocks until all are in position
  
  blind_1.disableOutputs();
  blind_2.disableOutputs();
  blind_3.disableOutputs();
  
  delay(5000);

  blind_1.enableOutputs();
  blind_2.enableOutputs();
  blind_3.enableOutputs();
  
  positions[0] = -CYCLE;
  positions[1] = -CYCLE;
  positions[2] = -CYCLE;
  steppers.moveTo(positions);
  steppers.runSpeedToPosition(); // Blocks until all are in position

  blind_1.disableOutputs();
  blind_2.disableOutputs();
  blind_3.disableOutputs();
  
  delay(5000);
}```
livid osprey
# median mica I need a code review. I'm using the AccelStepper/MultiStepper library. working f...

The reason for that is the positions[] array is initializing to 0. You have your code move it to CYCLE, which from 0 is half a rotation. After that point, you're either running the steppers from CYCLE to -CYCLE or vice versa, which makes one full rotation. If your intent is to make one full revolution forward and back, CYCLE should be set to 2048, and you should be changing your second set of positions[] to go to 0 instead of -CYCLE.

median mica
#

@livid osprey That was it. Thanks so much. I was getting mixed up with the positions.

gilded gazelle
#

I have 4.7k pull ups on whatever pin I use

desert bough
#

i am building a small musical synthesizer with an ItsyBitsy M4, but the default tone() function outputs a square wave. is it possible to output a sine wave? i know the board has a DAC but im not sure how to use it

livid osprey
# desert bough i am building a small musical synthesizer with an ItsyBitsy M4, but the default ...

The default tone() in Arduino is defined as a square wave with 50% duty cycle, for simplified compatibility with any digital pin. For a sine wave, you'll have to output from A0 or A1, as these two pins are the only ones capable of 12-bit digital-to-analog conversion. You can use a combination of I believe sin() and analogWrite() to output a sine wave (or any other waveform of your choice) on those two pins.

north stream
#

That is, in fact, exactly how I did this, using one output for vertical and one for horizontal.

pine bramble
#

So I have one of those genuino boards, basically a copy of arduino, and I recently bought one of these https://everyone-is.very-stinky.com/msedge_lyXhi0scYm.png and I've been trying to find where the pins it says would be on the genuino. (I would have bought a compatible sd card reader, but my original plan was to do this with a microcontroller that all all the pins. The microcontroller arrived dead and I don't have enough time to order a new one.)

pine bramble
#

Nevermind, I figured it out (hopefully)

ruby scarab
#

Has anyone used RemoteXY? Seems like the answer to my prayers for an iOS/Android app that can download a UI over bluetooth from my ESP32 and present that UI while using bluetooth terminal behind the scenes to do the actual comms. But I need something that will be around for years.

ruby scarab
#

Yeah I have to say I am impressed.

#

This is ESP32-C3 w/ Arduino IDE. Controlling the text from a custom "app" created with RemoteXY. This blows the doors off Dabble.

still zealot
#

I have a float array that i am wanting to write data that i recieve over uart to. If i just write it normally its fine i get all the numbers (e.g 1552) however if i divide by 100 first i dont get the decimal places and instead it just displays 0s (e.g. 15.00 instead of 15.52) any suggestions as to what could be causing this?

cedar mountain
zinc bridge
#

hey, I need a fixed width font for RGB matrix stuff, similar in size to Org_01 (6 pixels high) included with the Adafruit GFX library. Anybody have any recommendations?

ruby scarab
faint raft
#

I am assuming as a bitmap array or similar, not an actual font file like pcf?

zinc bridge
#

@faint raft whatever format the library can handle, though the smaller the better.

#

smaller files size, that is

faint raft
#

probably easiest with the bitmap array then

zinc bridge
#

I just want a fized with font where the 1 is teh same width as everythign else

faint raft
#

like Feldon said, you could draw your own font, and copy the values out there for each letter

#

I am having trouble remembering if there's any good 6px high fonts hahaha

#

I think the smallest I use is around 9px tall.

zinc bridge
#

I need something that will always bee the same width for a known number of characters, like times or dates. I don't like how Org_01 bounces around when 1s appear in the mix. 😦

sullen swallow
#

Anyone have an Arduoboy? (Not the FX). I just got one and am wondering if it's worth it to by the FX mod chip...

outer ivy
#

Hello, I am trying to use two SPI devices at the same time (one NRF24 module and a Micro SD card module). Both modules work fine when I connect just one, but when I connect both, the NRF module does not work anymore. After searching online I found it it had something to do with the level shifter on the sd card reader being active, even when the module was not in use (chip select low). Does anyone know if this problem also occurs with the adafruit sd card module? (https://www.adafruit.com/product/254) Thanks in advance!

inland gorge
north stream
#

You could add a tri-state gate in front of the MISO lead and drive it with CS to get around that

outer ivy
outer ivy
north stream
#

Yes, that fix would work with the board you have if I'm guessing right

#

And yes, it looks like the AdaFruit board would have the same issue

outer ivy
#

Do you have any part number i can look at for a tri state gate. I have never hear of that before. Thanks a lot for the help!

inland gorge
# outer ivy Do you have any part number i can look at for a tri state gate. I have never hea...

Generally the term you'd want is "bus transceiver". The 74*245 chip has an "output enable" pin that will isolate one side of its circuit from the other. Adafruit has a version of it that will also do 3V3-5V conversion: https://www.adafruit.com/product/735

outer ivy
north stream
elder hare
#
class movingSquares
{
public:
    uint16_t myDARK = virtualDisp->color565(64, 64, 64);
    uint16_t myWHITE = virtualDisp->color565(192, 192, 192);
    uint16_t myRED = virtualDisp->color565(255, 0, 0);
    uint16_t myGREEN = virtualDisp->color565(0, 255, 0);
    uint16_t myBLUE = virtualDisp->color565(0, 0, 255);

    uint16_t colours[5] = { myDARK, myWHITE, myRED, myGREEN, myBLUE };

    struct Square
    {
    float xpos, ypos;
    float velocityx;
    float velocityy;
    boolean xdir, ydir;
    uint16_t square_size;
    uint16_t colour;
    };

    int numSquares = 2;
    int minSize = 2;
    int maxSize = 10;
    Square Squares[numSquares];

    movingSquares(int numsquares, int minsize, int maxsize) : numSquares( numsquares ), minSize( minsize ), maxSize( maxsize )
    {

    }
};

error

include/Effects/square.h:30:20: error: invalid use of non-static data member 'movingSquares::numSquares'
     Square Squares[numSquares];
                    ^

how can i fix that?

north stream
#

You're trying to allocate an array without knowing what size it is. You can either make numSquares a non-varying quantity (const, #define, etc.) or you can allocate it dynamically with malloc() and cast the result.

#

A third possibility is to allocate it with the largest size you'll need and just use whatever portion of it required for circumstances.

elder hare
#

@north stream how does that malloc() thing work in this instance?

elder hare
#

i just read that malloc is not good to use on arduino because of fragmention

north stream
#

Basically you give it the number of bytes you need, and it returns a pointer to those bytes, which you cast into whatever kind of pointer you require. For example: ```arduino
Square * Squares = (Square *) malloc(numSquares * sizeof(Square));

#

Yes, malloc() is a bit dangerous on resource constrained systems like embedded processors. This is why I offered other suggestions.

elder hare
#

@north stream so then it would be this A third possibility is to allocate it with the largest size you'll need and just use whatever portion of it required for circumstances. then

#

as i want to be able to say numSquares, minSize, maxSize) in constructor of the class like

movingSquares squares(5, 2, 10);
north stream
#

Yeah, just allocate it with its maximum size, and maybe add a check in the constructor to see if the caller asked for more than that and return an error if so.

#

I'd probably make it a class (or instance) variable instead of declaring it in the constructor.

#

Or just make it global if it's going to be a singleton anyway.

elder hare
#

make what a class?

north stream
#

class variable

#

Your Squares array

elder hare
#

@north stream so instead of a struct make it a class?

north stream
#

I thought you already had a class (since you referred to a "constructor")

elder hare
elder hare
#

@north stream this works tho

template <size_t N>
class movingSquares
{
public:
    uint16_t myDARK = virtualDisp->color565(64, 64, 64);
    uint16_t myWHITE = virtualDisp->color565(192, 192, 192);
    uint16_t myRED = virtualDisp->color565(255, 0, 0);
    uint16_t myGREEN = virtualDisp->color565(0, 255, 0);
    uint16_t myBLUE = virtualDisp->color565(0, 0, 255);

    uint16_t colours[5] = { myDARK, myWHITE, myRED, myGREEN, myBLUE };

    struct Square
    {
    float xpos, ypos;
    float velocityx;
    float velocityy;
    boolean xdir, ydir;
    uint16_t square_size;
    uint16_t colour;
    };

    int numSquares;
    int minSize = 2;
    int maxSize = 10;
    Square Squares[N];

    
    movingSquares(int minsize, int maxsize)
    {
        minSize = minsize;
        maxSize = maxsize;
        numSquares = N;
    }
};

and then doing

movingSquares<4> squares(2, 10);
outer ivy
elder hare
cedar mountain
elder hare
#

question, is that not hard todo? collision detecting

cedar mountain
#

It's hard in the general case... things like arbitrary 3D objects in a game, for example. But for squares moving slowly in 2D, it's fairly straightforward, assuming that you actually have room for them all on the screen without overlapping.

steady badge
#

Quick question.. is it possible to create a program for arduino that will listen for keyboard input from the computer and then activate an output based on that input?

i.e. when you hold down 'z' it turns on an led

thanks!

cedar mountain
steady badge
still zealot
#

im working with a Nano 33 BLE. am i able to use mbed libraries such as BufferedSoftSerial with arduino?

cedar mountain
elder hare
#

does anyone know if fadeToBlackBy function in fastLED could that be done with the ESP32-VirtualMatrixPanel-I2S-DMA ?

elder hare
#

using the ESP32-VirtualMatrixPanel-I2S-DMA with fastLED colorFromPalette

    for (int x = 0; x < VPANEL_W; x++)
    {
      for (int y = 0; y <  VPANEL_H; y++)
      {
        int16_t v = 0;
        v += y * x * 255 / 8;
        currentColor = ColorFromPalette(currentPalette, (v >> 8) + 127);
        virtualDisp->drawPixelRGB888(x, y, currentColor.r, currentColor.g, currentColor.b);
      }
    }

why does it start at the top left corner and go down (see picture)
https://cdn.discordapp.com/attachments/637812536158453780/922558451148808273/20211220_193742.jpg

cedar mountain
elder hare
#

yea i got it fixed but im faced with another problem @cedar mountain

#

so im now using v += x * 255 / VPANEL_W*VPANEL_H; but the palette comes twice!

#

you see it starts with green and then in the middle you see it starts the palette again :S

#

this is the palette

DEFINE_GRADIENT_PALETTE( rainbow_gp )
{
      0,  255,    0,    0, // Red
     32,  171,   85,    0, // Orange
     64,  171,  171,    0, // Yellow
     96,    0,  255,    0, // Green
    128,    0,  171,   85, // Aqua
    160,    0,    0,  255, // Blue
    192,   85,    0,  171, // Purple
    224,  171,    0,   85, // Pink
    255,  255,    0,    0  // and back to Red
};
#

another thing i just saw

#

it should start on red :S

cedar mountain
#

Your prior code has (v >> 8) + 127, which offsets by 127, so that's probably why it's starting on green.

elder hare
#

i just removed the + 127 and now it starts with

#

yea

#

but it`s still displaying the palette twice :S

#

for some reason

cedar mountain
#

I think it might be an issue in your multiplication and division. Note that a / b*c is actually (a / b) * c rather than a / (b * c) as you might be assuming.

elder hare
#

i just based it off of my WS2812B FastLED script

ColorFromPalette(_ledsettings._palette_current, Index * 255 / _NumLeds);
cedar mountain
#

What's your panel width and height?

elder hare
#

128*128

#

4 x 64x64

cedar mountain
#

I'd expect it to only get halfway through the palette instead of going through it twice, then. Did you change the v>>8 shift amount?

elder hare
#

i tried but didn`t work

livid osprey
#

@elder hare is here a reason for using v += ... rather than just setting v = x/2 or v = x >> 1?

#

Or just not use v altogether and set currentColor = ColorFromPalette(currentPalette, x >> 3);

#

Actually, the easy fix to the palette repeating twice would be v += x / VPANEL_W; wouldn't it.

#

Man I don't even know how this palette thing works and I'm just making assumptions. Just try some of these options and see what happens?

elder hare
#

sadly non worked :/

#

@livid osprey

livid osprey
#

Not working as in still two palettes, or totally non-functional?

#

Can you post what your code looks like now?

#

Having it all in pieces is a bit hard to follow...

elder hare
#

it only showed 1 solid color (red)

livid osprey
#

Which one did? All of them?

elder hare
#

yea :S

cedar mountain
#

It's probably worth adding some print statements to examine what color values it's calculating. That'll probably help to explain what's going on. "When in doubt, print it out" is my troubleshooting mantra.

elder hare
#

found the problem

#
v = x * VPANEL_W / VPANEL_W*VPANEL_H;
mild cairn
#

guyss
please help
i have test a code with a bno055, it was working,the bno has broke,after i see a really cool board that was having all the sensor need for me and the imu on it is a lsm6ds33 and the same code,but with two different imu and that didnt work,i have look the two set of 3 gyroscopes from the imu should output in radians/s,im lost i dont know what to do i try plenty of thing,converting to degrees,changing pi value,see the velocity of seqdot,nothing has work

livid osprey
mild cairn
#

its a quaternion code

#

i means its just the lib key word that change

#

from

#
    wY = Gyro.y();
    wZ = Gyro.z();```
#

to```wX = gyro.gyro.x;
wY = gyro.gyro.y;
wZ = gyro.gyro.z;

livid osprey
#

Did you update your initializers to reflect the change in sensor?

#

Are your library imports updated to the new sensor?

#

If you're not using the Adafruit_Unified_Sensor class, you'll have to verify that the actual sensor outputs are equivalent, as raw data may differ from sensor to sensor, and the units these different libraries output could be different as well.

mild cairn
#

wait what the library unified sensor can change something?

livid osprey
#

It allows for easy switching of compatible sensors by standardizing units. I wouldn't know if it helps specifically in this case, but that's also only because I don't see the rest of the code in context.

#

Which library were you using for the BNO055?

mild cairn
#

for the lsm6 the lib is also from adafruit

twin wren
#

hey folks, i want to control this pwm fan with my arduino but im not sure which pin is which. notice the engraved print, im not sure if they could be of use. also the top wire has dashed lines, could this be the ground? i cant find the schematics for it anywhere.

cedar mountain
fiery bear
#
C:\Users\USERNAME\Documents\Arduino\libraries\Adafruit_NeoPixel\esp8266.c:20:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
 IRAM_ATTR void espShow(
           ^
exit status 1
Error compiling for board WeMos D1 R2 & mini.
#
#ifdef ESP8266
IRAM_ATTR void espShow(
 uint8_t pin, uint8_t *pixels, uint32_t numBytes, __attribute__((unused)) boolean is800KHz) {
#else
void espShow(
 uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) {
#endif

#define CYCLES_800_T0H  (F_CPU / 2500001) // 0.4us
#define CYCLES_800_T1H  (F_CPU / 1250001) // 0.8us
#define CYCLES_800      (F_CPU /  800001) // 1.25us per bit
#define CYCLES_400_T0H  (F_CPU / 2000000) // 0.5uS
#define CYCLES_400_T1H  (F_CPU /  833333) // 1.2us
#define CYCLES_400      (F_CPU /  400000) // 2.5us per bit

  uint8_t *p, *end, pix, mask;
  uint32_t t, time0, time1, period, c, startTime;

#ifdef ESP8266
  uint32_t pinMask;
  pinMask   = _BV(pin);
#endif

  p         =  pixels;
  end       =  p + numBytes;
  pix       = *p++;
  mask      = 0x80;
  startTime = 0;

#ifdef NEO_KHZ400
  if(is800KHz) {
#endif
    time0  = CYCLES_800_T0H;
    time1  = CYCLES_800_T1H;
    period = CYCLES_800;
#ifdef NEO_KHZ400
  } else { // 400 KHz bitstream
    time0  = CYCLES_400_T0H;
    time1  = CYCLES_400_T1H;
    period = CYCLES_400;
  }
#endif

  for(t = time0;; t = time0) {
    if(pix & mask) t = time1;                             // Bit high duration
    while(((c = _getCycleCount()) - startTime) < period); // Wait for bit start
#ifdef ESP8266
    GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinMask);       // Set high
#else
    gpio_set_level(pin, HIGH);
#endif
    startTime = c;                                        // Save start time
    while(((c = _getCycleCount()) - startTime) < t);      // Wait high duration
#ifdef ESP8266
    GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinMask);       // Set low
#else
    gpio_set_level(pin, LOW);
#endif
    if(!(mask >>= 1)) {                                   // Next bit/byte
      if(p >= end) break;
      pix  = *p++;
      mask = 0x80;
    }
  }
  while((_getCycleCount() - startTime) < period); // Wait for last bit
}

#endif // ESP8266
surreal pawn
#

well I wonder if I bricked nrf52840 sense. it's flashing amber LED fast and fading red on and off but doesn't enumerate as serial port

#

(I tried to update the bootloader with arduino and I thought that worked but it doesn't show up as device now and neither does brand new board)

#

if I double-press reset button on brand new board I don't get any device either. I'd expect to see UF2 bootloader drive

#

weird, it's like OSX blacklisted stuff under my USB hub

#

plugging in USB cable without using hub this time it works (i was able to upload bootloader and install circuitpython earlier with hub)

stable forge
gilded swift
# stable forge Sometimes rebooting macOS fixes USB port issues

I’m having weird USB issues with ESP32. Works fine in the REPL but trying to use ESP tool, can’t seem to communicate with it. I found if circuitpython goes into safe mode after a hard fault, I can upload. But something is happening where serial is bound up when in download mode.

#

this being if I’m trying to erase and upload a new bin

stable forge
#

if you leave tio open to the port, it blocks esptool

gilded swift
#

tio?

stable forge
#

it's like screen, minicom, etc.

#

close any REPL connection before uploading

gilded swift
#

it’s always closed. Unless having MU open is blocking it

#

But my devices don’t show up to use MU REPL

stable forge
#

I don't think so. what errors are you getting?

gilded swift
#

“Device not configured”

stable forge
gilded swift
#

We can switch to circuitpython help

stable forge
#

let's do

pine bramble
#

how do i make my analog 5w and ground give power out?

worthy elk
#

Hi guys, im currently working around this issue https://github.com/arduino/ArduinoCore-avr/issues/53
i am communicating to pro micro (32u4) trough webserial. everything is working full speed on win and linux. But on macos i have to send in 62 byte chunks with some delay between the cunks or the whole driver crashes. i have to reconnect the device to make it work again (as it says in the issue)

i now wanna see if i can work around it a bit better by using another usb-(serial?)-part for the pro micro.
is there a tinyusb implementation for the 32u4 i dont know about? any help is appreciated

GitHub

I have Arduino Pro Micro connected via USB to my Mac (Mac OS Sierra 10.12.6). Arduino IDE is 1.8.7, and the board is identified there as "Board: SparkFun Pro Micro / Processor: ATmega32U4 ...

livid osprey
pine bramble
stray coral
#

New here.
Is there any decent tutorial for hooking up QTPy M0 to a SD card breakout? I'm pulling my hair out, haha.

placid stone
#

Hello everyone! My name is Murat and i need some help about pov staff if its possible 🙂 I have uploaded the codes with little change, normally the code one the website it uses dotstar library but whenever i tried with dotstar i didnt get any light on leds then i've changed that dotstar to neopixel then i am able to see images but the thing is my staff have 72 leds when i download 72 pixel gif and convert it with python still i dont see any image. Hopefully someone can help me 🙂

jaunty fox
#

is there a recommended tutorial for having one arduino board access sensors on a second arduino board?

swift grotto
#

Hello, I am using the Adafruit PCA9685 servo driver for a project. The website recommends 5-6V for powering the servo motors and to use a 4xAA pack to power. My voltmeter is reading about 6.46V when checking the power supply; is it okay to use this or will I damage the board using over 6V? Thank you!

livid osprey
livid osprey
livid osprey
swift grotto
#

Oh I see. I read the limit for the Vcc and thought it was for V+. Thank you!

livid osprey
placid stone
#

@livid osprey i made it myself with ws2812 led strips

livid osprey
#

Which code are you using?

#

If possible, uploading your code would be preferable.

placid stone
livid osprey
#

So is it an issue with the neopixels not lighting up, or an issue of actually generating a persistence of vision image?

#

If I recall correctly, the PWM frequency of neopixels is a lot lower than Dotstars, hence why it's not typically used for such projects.

placid stone
#

when i try with this it works but when i convert new gif's its not working

livid osprey
#

The conversion is successful, but the images aren't working?

#

My first guess would be insufficient memory, if you scaled up the image size without changing the original Trinket out for something else.

#

@placid stone what hardware are you using?

placid stone
#

@livid osprey yes it uploads succesfully no memory error or any other errors. i am using df robot bluno beetle

livid osprey
#

Do you get any errors during runtime?

placid stone
#

nope not any erros i just see redlights thats all

#

for example when i try with 1 old gif which is works fine and 1 new gif which i converted the old one works but the new one isnt work

#

here is the pic which i converted

#

it is 154/72 pixels

stray coral
#

I was originally having issues with the chip select pin, and the microcontroller not recognizing the breakout board at all. Then someone suggested I should tie the chip select pin to power or ground to make it work, and it works when I tie it to ground. But now it recognizes that there isn't SD card, but can't figure out any of the partitions...

#

I am using the Arduino SD card example sketch just to try and get the SD card working properly. But I haven't been successful on any of my SMD microcontrollers. I have tried the protein near nano which is an effective Arduino zero, I have tried the trinket m0, and I have tried the cutie pie. All three have the same problem and I just don't know what to do.

livid osprey
placid stone
#

uhm so what do u suggest me to make pov with this blunobeetle ? smallew pics ?

#

smaller i mean

livid osprey
#

Definitely start with smaller images. I would not exceed 72x16, and for an initial test I'd try to go even smaller.

placid stone
#

@livid osprey thank you so much when i solve this image problem i will have couple questions too 🙂

elder hare
#

Im using the ESP32-HUB75-MatrixPanel-I2S-DMA lib with fastLED and a custom buffer so that i can use the fastLED on the matrix and what im trying todo is making a shootingStar / comet obvs im doing something wrong as when it fires off it draws a white line across the whole "screen" it`s not starting from one side and moving 1 dot across to the other side, here is the code (class) https://www.toptal.com/developers/hastebin/umubuqusok.cpp

placid stone
#

@livid osprey is it possible maybe this convert.py is corrupted ? becase now i ve tried with 16x16 but still no lights on leds

#

Sketch uses 9328 bytes (28%) of program storage space. Maximum is 32256 bytes.
Global variables use 99 bytes (4%) of dynamic memory, leaving 1949 bytes for local variables. Maximum is 2048 bytes.

livid osprey
#

Possible? not sure when it was written nor which version of Python it was written for. Have you tried both Python2 and Python3?

placid stone
#

let me try

stray coral
# livid osprey It should be fairly straightforward if you're just connecting the hardware SPI p...

I was originally having issues with the chip select pin, and the microcontroller not recognizing the SD breakout board at all. Then someone suggested I should tie the chip select pin to power or ground to make it work, and it works when I tie it to ground. But now it recognizes that there is an SD card, but can't figure out any of the partitions...
I am using the Arduino SD card info example sketch just to try and get the SD card working properly. But I haven't been successful on any of my samd microcontrollers. I have tried the protoneer nano which is an effective Arduino zero, I have tried the trinket m0, and I have tried the qt py. All three have the same problem and I just don't know what to do.

placid stone
#

@livid osprey pff my brain is frozen its kinda late here tomorrow i will continue thanks for help cya !

swift grotto
#

Hello

#

I am trying to use the PWMServoDriver library, but it didn't seem to be working. I added some print statements along the way to see where my code was getting stuck. It appears that after the pwm.begin(); function, the code doesn't proceed.

#

I can attach my code file for review if anyone is willing to help that would be greatly appreciated

tranquil shell
#

I'm looking for some help with adafruit's nr52 support for arduino. Is this a good place to ask ?

tranquil shell
#

thanks

#

it's adafruit-nrfutil. It crashed with a stackdump under linux mint

#

I think I had it working ok under debian 11 but I'm away from home with laptop and trying to work

#

this Mint has python 3.5.2. Not sure if that is relevant

stable forge
#

that's pretty elderly, so it may be restricted to quite an old version of itself or pyserial or other dependencies

tranquil shell
#

how can i find out ? It's only one Mint major release old, dont really want to upgrade

stable forge
#

3.5.2 is from 2016

#

is that the system-installed Python?

#

what is your mint version?

tranquil shell
#

it's still 3 though, right ? they wouldnt introduce an incompatibiilty on a minor release number would they ?

#

18.3

stable forge
#

no, but the libraries give minimum versions for what they support, so they might not upgrade to a more recent version without a newer version of Python. We just had an issue with one of our own libraries that was pegged at 3.7 minimum, and it quietly did not upgrade in GitHub Actions builds that were pegged at 3.6.

tranquil shell
#

does nrfutil has a published minimum version ?

stable forge
#

what is the version you have?

tranquil shell
#

i mean for python

#

but It crashed when running adafruit-nrfutil --version so unsure

stable forge
#

what is the backtrace?

tranquil shell
#

it's just today downloaded from adafruit

#

shall i post here or on a pad ?

stable forge
#

if big, upload here wihth "+" to the left or a pad

#

not a big deal

#

50 lines is fine

tranquil shell
#

Traceback (most recent call last):
File "/home/adrian/.local/bin/adafruit-nrfutil", line 7, in <module>
from nordicsemi.main import cli
File "/home/adrian/.local/lib/python3.5/site-packages/nordicsemi/main.py", line 32, in <module>
import click
File "/home/adrian/.local/lib/python3.5/site-packages/click/init.py", line 7, in <module>
from .core import Argument as Argument
File "/home/adrian/.local/lib/python3.5/site-packages/click/core.py", line 84
f"{hint}. Command {base_command.name!r} is set to chain and"
^
SyntaxError: invalid syntax

#

it seems to be complaining about the syntax of printing a warning, but that's because something already failed

#

raise RuntimeError(
f"{hint}. Command {base_command.name!r} is set to chain and"
f" {cmd_name!r} was added as a subcommand but it in itself is a"
f" multi command. ({cmd_name!r} is a {type(cmd).name}"
f" within a chained {type(base_command).name} named"
f" {base_command.name!r})."
)

stable forge
#

that is an "f-string", introduced in Python 3.6

#

to paste code-like stuff, see hints for using backticks at the bottom of the #general-tech channel

tranquil shell
#

thanks. more usewd to irc, and my favourite etherpads all seem to have died

stable forge
#

You could install a newer version of Python and create a venv to run it in. I don't know whether Mint has its own packages for that. I use the deadsnakes ppa on Ubuntu

#

click looks like it is too new

tranquil shell
#

gonna be messy, because it's being run by the arduino download script

stable forge
#

I think you may want to bite the bullet and upgrade, but if you are remote I guess you don't want to risk trashing the laptop

tranquil shell
#

but at least i know what's wrong now

#

yeah. though its got an old hd in it. I could leave this ssd alone and upgrade that. just feels a bit like yak shaving. Or xkcd's shark comic.

stable forge
tranquil shell
#

heh. yeah that sums up my experience of python well. I was very glad to see that one 🙂

#

I wish pythonistas were as careful as henry spencer in avoiding using new features

#

Thy external identifiers shall be unique in the first six characters, though this harsh discipline be irksome and the years of its necessity stretch before thee seemingly without end, lest thou tear thy hair out and go mad on that fateful day when thou desirest to make thy program run on an old system.

tranquil shell
#

@stable forge OK, I ran it with python3.7 but now it's not finding the nordic parts :

#

Traceback (most recent call last):
File "/home/adrian/.local/bin/adafruit-nrfutil", line 7, in <module>
from nordicsemi.main import cli
ModuleNotFoundError: No module named 'nordicsemi'

stable forge
#

you'll need to set up a venv or virtualenv and reinstall (via pip3) the dependencies inside the venv

tranquil shell
#

ok. I tried just changing the interpreter path in the script. Not enough ?

stable forge
#

no, because the pip3 installs are specific to a version

tranquil shell
#

ok ta

stable forge
#

e.g installed in ~/.local/lib/python3.8/...

tranquil shell
#

so I would need to rerun the adafruit library install inside the venv in order to get the nordic sdk in the right place ?

stable forge
#

i think you can just do pip3 install adafruit-nrfutil inside the venv. It will pick up the dependencies it needs.

tranquil shell
#

yay! works 🙂

stable forge
desert bough
#

nooby question, is there a way to make the DotStar not glare a harsh pink on a Trinket while arduino code is running? do I have to break out the dotstar library or is there a simpler fix?

pine bramble
#

@desert bough I usually turn it off manually in the code (yes, with the library).

#
include <Adafruit_DotStar.h>
#define NUMPIXELS 1 // Number of LEDs in strip
#define DATAPIN    3
#define CLOCKPIN   4

Adafruit_DotStar strip = Adafruit_DotStar(
  NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);

void setup_dotstar() {
  strip.begin(); // Initialize pins for output
  strip.show();  // Turn all LEDs off ASAP
}
#

That might be enough.

#

adjust the pins to your target board.

#

Source was here (and is a mess):

elder hare
#

hmmm is it not possible to Blur only 1 pixel? im trying with the fastLED blur2d but it blurs the entire matrix display! i only want to blur my moving pixel (1 pixel)

#

what im trying to make here is; i have 1 pixel that spawns from the right and then moves all the way to the left with a pixel trail behind it (kinda like a comet) and i want to "blur" the head/leading pixel

cedar mountain
elder hare
#

@cedar mountain yea that is what im trying atm

obtuse spruce
#

Clearly I've drunken too much eggnog and need another pair of eyes.....

The following foo.ino file compiles (but clearly doesn't link as it doesn't have setup or loop code):

enum action_t { stop, start, pause };
void doAction(action_t act) { }

But the following bar.ino file fails to compile:

void setup() { }
enum action_t { stop, start, pause };
void doAction(action_t act) { }

gives the error:

dmastall:53:15: error: variable or field 'doAction' declared void
   53 | void doAction(action_t act) { }
      |               ^~~~~~~~
dmastall:53:15: error: 'action_t' was not declared in this scope

How is having a function declared before the enum causing the following function to fail to parse????

obtuse spruce
#

ah! thanks that’s it exactly!

stable forge
#

If you look in /tmp/arduino_build_nnnn, you'll see a .cpp program, like:

include <Arduino.h>
#line 1 "/home/halbert/Arduino/sketch_dec25a/sketch_dec25a.ino"
#line 1 "/home/halbert/Arduino/sketch_dec25a/sketch_dec25a.ino"
void setup();
#line 2 "/home/halbert/Arduino/sketch_dec25a/sketch_dec25a.ino"
void loop();
#line 4 "/home/halbert/Arduino/sketch_dec25a/sketch_dec25a.ino"
void doAction(action_t act);
#line 1 "/home/halbert/Arduino/sketch_dec25a/sketch_dec25a.ino"
void setup() { }
void loop() { }
enum action_t { stop, start, pause };
void doAction(action_t act) { }
#

Note the early forward declaration just below the #line 4, which precedes the actual enum

#

it should be smarter about doing a forward decl of the enum (I'm not sure that's possible, but maybe it is0S

obtuse spruce
#

got it.. it’s making forward decls for everything in *.ino
meh!

stable forge
#

so just move all your decls to before setup and loop, I guess

obtuse spruce
#

wish you could turn that off - trying to make a one file sketch to go with a bug report

pine bramble
#

I keep the .inofile empty of any code and use .cpp files.

#

Each .cpp file takes an

#include <Arduino.h>
#

There's some finite chance the compiler will behave better in that instance.

obtuse spruce
#

yeah.. i’m usually a many small files guy… but i wanted a single file for this bug… ah well…

pine bramble
#

You can have a single .cpp and what do you care if an empty .ino file litters the directory? ;)

obtuse spruce
#

for me, i don’t just for posting “here this sketch shows the bug”

pine bramble
#

I get that, sure.

#

The bug is arduino.cc though. ;)

#

They just had to mess with something standard.

surreal pawn
#

How do the interrupt handlers compile when they aren't defined? samd21j18a.h has declarations for every interrupt handler but usually the functions themselves don't get implemented

cedar mountain
#

Often there is some boilerplate code with "weak references" for each handler to a placeholder infinite-loop function, which the compiler will use if no other code provides a real function definition.

surreal pawn
#

If you're using harmony or asf they define the interrupt handler functions, mark it as handled, and call a user function pointer if one has been set. If not using ASF or harmony, I don't understand what happens

cedar mountain
surreal pawn
#

that's it. thanks

#

well, I don't think that's part of the adafruit arduino samd core

static oracle
#

Looking for help with a neopixel-- my matrix is stuck just booting up the first (0,0) pixel and won't respond otherwise-- any resources appreciated

leaden walrus
#

more info would help. what all hardware is being used? what code is being run?

bright shale
#

Anyone awake?

simple hinge
#

Hey

#

To connect an SX1278 LoRA Module, I need to use D9-D12 pins

But I also want to connect an SD Card

The SD Card Module uses the same pins as well!

Any solutions please?

odd fjord
#

The SDCard will share the SCK, MISO and MOSI lines with the radio. It just needs a unique chip select

simple hinge
#

Okay thanks

odd fjord
#

You don’t seem to have CS connected to your radio board. You will need it.

#

Are you following a guide? Can you post a link to it. Your wiring looks odd. Using EN but not CS…

#

If you want to use both the SD card and radio, both will need CS connections.

surreal pawn
#

Is Arduino 2.0.0 going to a rough upgrade or easy?

deep hazel
#

there appears to be a problem with the pin definitions for the arduino-pico core for the QT Py RP2040 and when i'm using them in projects i just kind of work around it and make my own defines with the pins i need but i figured if i'm having those issues everyone else trying to use it with that core likely is too, so my question is: if i figure out the mappings for everything can i just submit a PR to Adafruit's fork (or even the main earlephilhower repo) or is that something that someone at Adafruit would be able to fix up easier/quicker than i likely could?

deep hazel
# surreal pawn Is Arduino 2.0.0 going to a rough upgrade or easy?

ehh, it's a bit of a pain because you have to "reinstall" your boards/libraries because it doesn't pick them up automatically, and it also doesn't seem to pick up libraries just placed inside the libraries directory like the original IDE did, and the whole board/library management experience is a huge step backwards compared to how the original IDE does it although the modern creature comforts in the new IDE are a nice addition

stable forge
deep hazel
stable forge
#

I think it would be good to bring it up in the forums to make sure there isn't a misunderstanding about the pin mappings first.

deep hazel
#

good point

stable forge
# deep hazel good point

@ me with the URL of the forum post and I'll see it gets some attention. Going to sleep now 🙂

deep hazel
#

though looking at all that right now i can already see why i've had some weirdness in the past, A0-A3 have their physical pins reversed compared to what they're supposed to be set to

#

so A0 is A3 and A1 is A2 lol

stable forge
#

maybe also look at, say, the Feather RP2040 as well so see if you think it has the same issue.

#

That may well be just an error. Few people are using Arduino for these boards

deep hazel
#

haven't noticed any issues with my Feather RP2040, that one works 👌

#

yeah i know the QT Py boards are really intended for CircuitPython but... that form factor lol... it's just the right amount of IO for most of my projects

deep hazel
forest cape
#

Hi I want to control current that goes to LED with AD5821, does anyone know how to do it? I couldnt understand the datasheet 😦

cedar mountain
#

It looks like the I2C protocol is pretty simple... just two bytes to send the output current you want with a little bit-shifting into the correct offset.

forest cape
# cedar mountain It looks like the I2C protocol is pretty simple... just two bytes to send the ou...

I thought so too. I am using Adafruit Feather RP2040 and writing it in C. So I created a function called setCurrent and what this funtion does is to write the current output by implementing the bit shifting, which can be seen in the code below.

bool setCurrent(uint16_t output){
    uint8_t data[2];
    data[0] = (output / 16) >> 2; //MSB (x.x.D9.D8.D7.D6.D5.D4)
    data[1] = (output % 16) << 4; //LSB (D3.D2.D1.D0.x.x.x.x)
    // i2c_write_blocking(i2c, ADDR_AD5821, data, 2, false);
    reg_write(i2c, ADDR_AD5821, data, 2);
    return true;
}
#

in main method i wrote the following code to test whether it works or not. if it works, the led should be turned on.

while(true){
   printf("Current:");
   setCurrent(512);
}
#

in case you are confused with reg_write function, I found it on the internet and it's basically a write protocoll in i2c.

int reg_write(  i2c_inst_t *i2c, 
                const uint addr,  
                uint8_t *buf,
                const uint8_t nbytes) {

    int num_bytes_read = 0;
    uint8_t msg[nbytes];

    // Check to make sure caller is sending 1 or more bytes
    if (nbytes < 1) {
        return 0;
    }

    // Append register address to front of data packet
    
    for (int i = 0; i < nbytes; i++) {
        msg[i] = buf[i];
    }

    // Write data to register(s) over I2C
    i2c_write_blocking(i2c, addr, msg, nbytes, false);
    return num_bytes_read;
}
#

During the build, no error is found. However, my led is not turned on. I really appreciate all of the feedback this community can give, as I am a bit frustrated by this simple logic lmao

obtuse spruce
#

@forest cape - your shifting is wrong

#
    data[0] = (output / 16); //MSB (x.x.D9.D8.D7.D6.D5.D4)
#

no need to shift on the upper byte... the divide does that

#

Another way to do this is with just shifting:

    data[0] = output >> 4; //MSB (x.x.D9.D8.D7.D6.D5.D4)
    data[1] = output << 4; //LSB (D3.D2.D1.D0.x.x.x.x)
#

Also, the high bit in data[0] will initiate shutdown if 1... so you want to avoid that:

bool setCurrent(uint16_t output){
    output = min(output, 0x3ff);  // clamp to 10 bit range
    uint8_t data[2];
    data[0] = output >> 4; //MSB (x.x.D9.D8.D7.D6.D5.D4)
    data[1] = output << 4; //LSB (D3.D2.D1.D0.x.x.x.x)
    // i2c_write_blocking(i2c, ADDR_AD5821, data, 2, false);
    reg_write(i2c, ADDR_AD5821, data, 2);
    return true;
}
forest cape
obtuse spruce
#

if the input were accidentially greater than 1023, then you run the risk of setting the shutdown bit in the command (high bit of data[0])

#

since the DAC only takes 10 bits, 0 to 1023 (0x3ff) - this line just makes sure the input is in range

forest cape
#

Okay understood. I still need to define the min function. I implemented this code: #define min(X,Y) (((X) < (Y)) ? (X) : (Y)) and tested it. However, it still hasn't brought me any luck. Is this min method already defined in stdlib.h or did I write it incorrectly?

obtuse spruce
#

it is defined in Arduino.h i believe

forest cape
#

I find that the min function is unnecessary for my use case, since I already defined the input manually. It is still not working and could it be that the reg_write function is the reason it wont work?

north stream
valid cradle
#

Hello,
I'm a newby with Arduinos and have a problem with my 3.5inch tft lcd shield from WaveShare (ILI9486) . (and I'm sorry for my english)
I can draw something on my Display, I can read my sd-card, i can read if a specific file is on the sd card, but i cannot open it/draw the picture.
Could somebody help me?

My Inclusion

#include <Arduino.h>

#include <SPI.h>

#include <ILI9486_SPI.h>

#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
#include <Waveshare_ILI9486.h>

#include <SdFat.h>
#include <Adafruit_ImageReader.h>

My tft and my sd declaring

namespace
{
  Waveshare_ILI9486 Waveshield;
  Adafruit_GFX &tft = Waveshield;
}

SdFat SD;
Adafruit_ImageReader reader(SD);

The Part which is not working:

ImageReturnCode stat;
stat = reader.drawBMP("/logoMuV.bmp", tft, 0, 0);

tft is marked red: "A reference of type "" Adafruit_SPITFT & "" (not constant qualified) cannot be initialized with a value of type "" Adafruit_GFX "". C / C ++ (434)" (translated from German)

native dagger
#

Can't comment on the code, but you can do multi-line code blocks with syntax highlighting with
```cpp
Code
```

valid cradle
#

I did😅

native dagger
#

Oh. It showed up weird on my phone at first but it looks normal now

obtuse spruce
#

tft is an Adafruit_GFX, but the function drawBMP wants an Adafruit_SPITFT

#

if Waveshare_ILI9486 is a subclass of Adafruit_SPITFT, then pass Waveshield, not tft to drapBMP

faint raft
#

eagle eyes

obtuse spruce
#

debugging is the art of forgetting everything that you "know" as you read the code

faint raft
#

I am just terrible at reading code without syntax highlighting.

#

but yeah, I shouldn't have tried to read any of those code snippets, because they actually didn't help explain the issue, at all. Only way I could prove anything in either direction would be to duplicate that code locally and then try to run it. Without a complete context of what is breaking.

#

Ignoring the code and just looking at the error completely explains everything.

valid cradle
#

Sadly Waveshare_ILI9486 is not a subclass of Adafruit_SPITFT

#

I just can't find a type subclass of Adafruit_SPITFT working with my tft shield
I'm struggling with this Problem since 2 weeks

faint raft
#

because that's where the issue is at

#

and then you branch out into the Adafruit code

valid cradle
valid cradle
# faint raft Where does `ImageReturnCode` come from?

From a guide about ImageReader. Idk if I'm allowed to post here links.

But wait I think you already helped me out, many eyes and some new ideas can help sometimes.
I think I'm using the ImageReturnCode not as supposed from the guide.

faint raft
#

yup

valid cradle
#

But don't i need the ImageReturnCode to load the image and to check the size of it?

valid cradle
forest cape
forest cape
rough torrent
valid cradle
dusk nymph
#

anyone happy to tell me why I get src/MCP3x6x.h:213:78: error: cannot call member function 'uint8_t MCP3x6x::_write(uint8_t*, uint8_t, size_t)' without object
union config0{ uint8_t data; struct { uint8_t ADC_MODE:2; uint8_t CS_SEL :2; uint8_t CLK_SEL :2; uint8_t VREF_SEL:1; uint8_t CONFIG0 :1; }; inline uint8_t write() {return _write(this->data, MCP3x6x_ADR_CONFIG0);}; // inline uint8_t read() {return _read ( &data, MCP3x6x_ADR_CONFIG0);}; };
https://gist.github.com/nerdyscout/db5bec52105e4a6bc71ef133cdc0ac25
https://gist.github.com/nerdyscout/6fc77ccbcef0c0d7482ed16c92c2c7f2

Gist

GitHub Gist: instantly share code, notes, and snippets.

Gist

GitHub Gist: instantly share code, notes, and snippets.

north stream
surreal pawn
#

Does the peripherals view when debugging in platformio actually work or is my code broken?

#

(feather m0 express trying to configure AC because reasons)

surreal pawn
#

eh, I don't see what's wrong with my code either

surreal pawn
#

turns out debugger was correct. If you don't power up a peripheral setting its registers won't change much

#

generated code like PM_REGS->PM_APBCMASK = 0x30022; is kind of opaque

dusk nymph
surreal pawn
#

Huh, looks like that's changed

surreal pawn
wheat wadi
#

hi, is there a way to feed an arduino uno an unregulated 5V (like the usb input) without going through the usb port ?

surreal pawn
#

not 5V

north stream
#

You should be able to power it by providing 5V on the 5V pin.

wheat wadi
#

oh, thought the 5v was only output. Thats makes life easier

wintry falcon
#

Hey guys, I just used my brand new Adafruit Airlift ESP32 Breakout board

#

used it to get informations from a website every 0.5 seconds

#

Now my arduino says that the communication with the wifi module failed

#

is the board broken?

#

Can I test this anyhow?

obtuse spruce
#

Then run that test code.

#

I think that page also has an Arduino based setup if you don't want to do Circuit Python

safe shell
#

or a most basic test, if you have a USB-to-UART, you could see if you can communicate with it using esptool using just 3 pins

halcyon portal
#

Is there a migration / change guide for the Adafruit_MCP23017 library? the v2 release seems quite different (MCP23X17, no pullup() function, etc) and all I can really see is the GH diff "major update", is this discussed somewhere that I'm missing?

pallid eagle
#

the adafruit tutorial doesn't mention anything about using it with arduino so i thought i would ask here

north stream
#

Yeah, should work fine, just choose the appropriate adapter cable

pallid eagle
north stream
pallid eagle
#

I was confused because the Stemma speaker has 3 pins instead of 2

#

would i just connect the signal pin to the pin i called the tone() on?

north stream
#

I think the 3 pins are power, ground, and signal. And yes, you'd hook the signal lead to the pin you call tone() on.

verbal rain
#

I am trying to use a OLED display with the adafruit circuit playground express, but whenever I include the line display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS); in the setup() function, the built in left button (D4) stops working and remains high no matter what. But the right button (D5) still works properly

#

The display works properly, and without the display.begin line the left button also works properly, the issue is only when both the display and left button need to be used. Is there something I have to change in the variant.cpp for the circuitplayground?

#

Full code with error:

#include <TimeLib.h>
#include <Adafruit_CircuitPlayground.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET     4
#define SCREEN_ADDRESS 0x3C //0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET, SCREEN_ADDRESS);
void setup() {
  Serial.begin(9600);
  CircuitPlayground.begin();
  display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
  display.display();
  display.clearDisplay();
}

void loop() {
  // this just prints 1
  Serial.println(CircuitPlayground.leftButton());
  delay(1);
}
livid osprey
#

My advice would be to change the oled reset definition to a different pin, separate from the built in tact switches.

fervent verge
#

Are there anything for microcontrollers similar to boost::graph ? something where I can create nodes, connect them, and then create a traversal list? I've found a few basic implementations in C but I wasn't sure if there was anything out there optimized for microcontrollers.

verbal rain
stable forge
fervent verge
#

Definitely can't find anything thats a "for sure" option. I might just write my own since my needs are fairly simple but have some nuance

pallid eagle
#

Can someone tell me what these 6 pins are for? (The wires are there because a schematic I was using had them there)

north stream
#

I'm guessing they're an ISP port (typically a 2x3 header block) or a serial port (typically a 1x6 header block)

safe shell
#

not clear what board that is, but some similar boards use it for SPI

north stream
#

Note: ISP uses SPI, so that port is often used to get SPI signals offboard

safe shell
#

ah, did not know about ISP

pallid eagle
#

Is the thing that is inside a purple circle with a star next to it that thing?

#

I’m guessing yes?

safe shell
#

looks that way... ICSP (in-circuit serial programming)

pallid eagle
#

The main issue is that I have run out of ground pins and it’s difficult for me to connect more then one thing to a pin

#

Something uses those 5v and ground pins so I figured I would ask

#

It’s not too much bigger

north stream
pallid eagle
#

I need something really tiny because this is for a cosplay with limited space and I am using the header pins and socket cables

north stream
#

The 4x4 breadboard is smaller than the snap-action connector and you can plug jumper wires straight into it.

pallid eagle
#

Is there some sort of really small Y socket/header/jumper cable?

#

The other issue is that this is right by my face

north stream
#

The next step is rolling your own, either with wire nuts or cutting, soldering, and insulating (with, say, heat shrink tubing)

pallid eagle
#

Could I theoretically cut and solder the jumper wires that I already have into a Y ?

north stream
#

Yup. I do that sort of thing a lot.

pallid eagle
#

Ok

#

I have the stuff already anyways

#

Then I will be able to add that speaker to this project

inland anvil
#

If I wanted to make a very tiny fan (the size of a quarter) turn on and off via a remote control, would the fan need its own separate power supply?

cedar mountain
#

As opposed to what?

inland anvil
#

As opposed to being powered by the arduino itself

#

I’m trying to get this working with the smallest possible components Take up the least amount of space as possible

cedar mountain
#

It might work, but it would just depend on the specs of the fan, in terms of required voltage and max current draw.

inland anvil
small pumice
#

Using the Arduino WiFi webserver example code, I am trying to parse data from a PUT. If I comment out the /n and /r logic, I can see the data two lines below the conect type, but it hangs due to no response. If I include the full logic the info printed by Serial.write(c); ends before the parameters are displayed. Sending from a Pi using requests library and params = {'c': '45', 'd': '123'}
r = requests.put('http://192.168.1.36/', data = params)

raven vale
#

My Feather STM32F405 won't show up as a listed Serial Port in MacOS - am I missing someting?

stable forge
raven vale
#

ok, thanks @stable forge - I was/am trying to read ADC values in Serial monitor from a simple cpp program loaded via STMduino so I guess no dice for this board?

#

I actually gave up and now I'm using a feather rp2040 and it's working fine 😛

stable forge
#

answering things in four different channels

raven vale
#

Thanks! A headache for another day I think haha

safe halo
#

I am trying to read an MPU6050 and I have a main.cpp and an imu.cpp with the matching header files. I have added imu.h to the main.h
Whenever I add

Adafruit_MPU6050 mpu;```
into my main.h I get a compile error .
```text
.pio\build\esp-wrover-kit\src\main.cpp.o:(.bss.mpu+0x0): multiple definition of `mpu'
.pio\build\esp-wrover-kit\src\imu.cpp.o:(.bss.mpu+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\esp-wrover-kit\firmware.elf] Error 1

main.cpp

#include "main.h"

imu.cpp

#include "imu.h"

main.h

#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include "imu.h"
Adafruit_MPU6050 mpu;

imu.h

#include "main.h"
fervent verge
# safe halo I am trying to read an MPU6050 and I have a main.cpp and an imu.cpp with the mat...

Its a little odd that imu.h also includes main.h - generally you want to avoid circular dependencies like this - but also look at include guards: https://en.wikipedia.org/wiki/Include_guard

In the C and C++ programming languages, an #include guard, sometimes called a macro guard, header guard or file guard, is a particular construct used to avoid the problem of double inclusion when dealing with the include directive.
The C preprocessor processes directives of the form #include <file> in a source file by locating the associated fi...

#

Basically, wrapping your header in the include guard will make sure that even if its included in multiple files, it only gets added once. Usually you wouldn't wrap main in the include guard but since you have it included in imu.h you have 2 mains and 2 global Adafruit_MPU6050 mpu's with the same name

cedar mountain
#

Variable definitions should usually be done in .cpp files instead of in headers. If you want to expose them to other modules, they can be declared as extern in the header file, but they should only have a single real definition across the whole program.

fervent verge
#

Well global ones 🙂 Defining them inside classes and structs in headers is fine depending on your coding style

cedar mountain
#

Sure, I meant anything that actually instantiates a variable in memory.

grizzled atlas
#

Hey guys I have been working hard on my Featherwing with the M4 express and it is working very nice. I have it loading images from the SD card now in Arduino and I have built a menu system. Today I added a AirLift Featherwing ESP32 Co-Processor and got that scanning and connecting to Wi-Fi also creating a AP to host a config page. The issue I have now is when I connect the M4 with the AirLift attached to the Keyboard Featherwing the MicroSD no longer detects as I think the SPI is conflicting with the AirLift as that also talks over SPI. Does anyone have any ideas how I can make them work together? Please 😁

obtuse spruce
#

@grizzled atlas - if they are both using SPI, then each will need a separate CS pin... are they using the same by default?

#

Looks like the ESP32 Co-Processor use D13 as the CS line

#

it also uses D11 and D12 - and if you soldered the jumpers on the board a few others

grizzled atlas
#

@obtuse spruce Thank you I am not sure what the keyboard Featherwing uses I am looking into it now.

obtuse spruce
#

Do you have the version sold by Adafruit, or the V2 from the tindle store? Either way it uses D5 as the SDCard SPI CS line

#

unfortuneately it looks like the the Keyboard thing uses D11 for NeoPixels

grizzled atlas
#

Yeah the neopixel on the front uses D11

obtuse spruce
#

So there you have a conflict... though I'd think the SDCard would work no matter what and only the Coprocessor would fail

grizzled atlas
#

That's what I would have thought. Not sure how I will solve this. Funny thing I dont use the neopixel. Thank you.

obtuse spruce
#

simple: disable the NeoPixel -- easiest way, depending on how you have the feathers all stacked, is to just clip the D11 pin between the keyboard and rest of the feathers!

#

then you won't be damaging the the keyboard featherwing should you decide to repurpose it in the future

#

OH

grizzled atlas
#

Perfect! I'll give it a try.

obtuse spruce
#

or there is a solder trace you can cut with an exacto knife

#

on the back of the keyboard thing - underside between the connectors!

#

if you ever want it back, a blob of solder restores it!

#

that's even better than pin cutting

grizzled atlas
#

ok, so to recap I need to soldier some pads on the AirLift to use D11 and D12 and break the D11 on the keyboard for the neopixel

obtuse spruce
#

That is one nicely designed FeatureWing, actually! I'm impressed

grizzled atlas
#

Its super nice.

obtuse spruce
#

No - nothing to solder on the AirLift - it is fixed that way

#

all you need is to use a knife to cut the trace between those two exposed pads for D11 / NeoPixel on the keyboard

#

The solder pads on the AirLift are for additional things - none of which you likely need

#

(and will conflict with more things on the Keyboard)

grizzled atlas
#

ok I just change the airlift pin in the code to 11?

obtuse spruce
#

no no

#

NOTHING to change int he Airlift code....

grizzled atlas
#

ok, sorry I dont understand how the AirLift knows to use the D11 to stop conflicting?

obtuse spruce
#

The CS pin is still D13... but it turns out AirLift uses two additional lines (not SPI related), on D12 and D11 --- they are already connected, can't be disconnected, and can't be reassigned

grizzled atlas
#

Got it!

obtuse spruce
#

In otherwords, the AirLift uses SPI + D13 for communication - BUT also uses D12 and D11 as simple digital pins for other indications - and I'm assuming the driver library has those hard coded... since they are hard wired

#

The keyboard is use D11 for NeoPixels - but you can stop that by cutting the trace... and boom should be good. The keyboard is using SPI + D5 for SD Card communication and that should be fine as is.... so long as you didn't put blobs of solder on the optional pads on the back of the AirLift

grizzled atlas
#

Doing it now. 😁

grizzled atlas
#

OK, neo pixel no longer works but the MicroSD card also does not work.

grizzled atlas
#

@obtuse spruce Thank you very much for trying to help me.

obtuse spruce
#

waaaaaa sorry

#

@grizzled atlas - if you wire everything up - but comment out all the code dealing with the AirLift.... then does the SD card work?

grizzled atlas
#

No.

obtuse spruce
#

hrm.... we are all missing something here because there should be no problem with sharing those SPI lines

grizzled atlas
#

Yeah I am stumped. If I remove the AirLift board then the sd works. If I just have the M4 express and the AirLift without the keyboard then I get WiFi etc?

obtuse spruce
#

So - I'm wondering if one or the other is setting the SPI clock too fast for the other

#

you could try to force the clock speed by running this after you call .begin() on both subsystems:

    flastTransport.setClockSpeed(4000000, 4000000);
grizzled atlas
#

ok, ill try it now

obtuse spruce
#

er - the flashTransport device you're using for the card

#

(I'm improvising code here...)

#

Eh - feh - nevermind

#

that's all wrong - I just checked, the SD file system code forces the clock to what it needs on each transaction

#

And, er, you do have

  #define SPIWIFI       SPI  // The SPI port
  #define SPIWIFI_SS    13   // Chip select pin
  #define ESP32_RESETN  12   // Reset pin
  #define SPIWIFI_ACK   11   // a.k.a BUSY or READY pin
  #define ESP32_GPIO0   -1
//...
  WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);

somewhere near the top of your sketch that does both keyboard and wifi, right? -- Just checking

grizzled atlas
#

yes

#

I just tried running standalone WiFi code only with the keyboard attached and it failed.

obtuse spruce
#

so to recap: M4+CoProcessor -> WiFi standalone works ; M4+Keyboard -> SDCard code works ; M4+CoProcessor+Keyboard -> neither WiFi standalone nor SDCard code work

grizzled atlas
#

Agreed.

obtuse spruce
#

(BTW how are you getting all three to attach? Feather double board? stacking headers?

grizzled atlas
#

Stacking headers. from keyboard, next layer is AirLift then M4 Express

obtuse spruce
#

should be fine.... power? from USB I assume?

grizzled atlas
#

yeah and or lipo

obtuse spruce
#

not sure what the on/off switch on the keyboard featherwing does - presumably turns off the display? Wondering if... when all stacked, if that is off, if WiFi standalone code works

grizzled atlas
#

it powers on and off the whole unit. Even when on usb

#

so you need the switch on to flash it

#

I just flashed the standalone wifi code only and connected it to the board and it now works.

#

This code does not try to use the sd

obtuse spruce
#

and it works with the keyboard feather on - whether on or off?

grizzled atlas
#

yes. I am going to add a basic sd card test to this code.

#

Cant read the SD card

#

Code should have listed the files on the card.

obtuse spruce
#

and we've established that using the same code, but not ever calling into the WiFi library (even to set it up) - still causes nothing to be read?

#

(I'm trying to see if we can debug if it is HW or SW related)

grizzled atlas
#

Agreed.

obtuse spruce
#

at this stage I'd be getting out my oscilloscope... but only as this is agood way to debug....

#

the implication here is that something electrical on the CoProcessor is interfearing with the SDCard

#

WAIT - are you successfully writing to the display ?

grizzled atlas
#

yes

#

display, touch screen, buttons etc all work.

#

even the ALS

obtuse spruce
#

okay - so perhaps we are barking up the wrong tree here....

#

the display uses SPI (CS=D9)

#

so if you can do SPI to the display AND SPI to the WiFi - then seems to me that the WIFi board isn't mucking up SPI - and is playing nicely

grizzled atlas
#

yes cs=D9

obtuse spruce
#

Now - the only two things that should be different between display and SDcard is the CS line

grizzled atlas
#

Yes. Display uses 9 and sd uses 5

obtuse spruce
#

and D5 - used by the SDCard - shouldn't be hooked to anything on the WiFi board

#

okay - just maybe - try this -

flastTransport.setClockSpeed(1000000, 1000000);
grizzled atlas
#

Dont think so.

obtuse spruce
#

setting the SDCard to go slower? Maybe it is just too fast with all the load on the SPI lines?

grizzled atlas
#

Doing it now.

#

Cant get that command to work. I have put it after each module begin?

obtuse spruce
#

I have:

  Adafruit_FlashTransport_SPI flashTransport(
      EXTERNAL_FLASH_USE_CS, EXTERNAL_FLASH_USE_SPI);

  Adafruit_SPIFlash flash(&flashTransport);

  FatFileSystem fatfs;
//...
    if (!flash.begin()) {
      errorMsg("Failed to initialize flash chip.");
      return false;
    }
    flashTransport.setClockSpeed(4000000, 4000000);
      // flash is just flaky at higher speeds it seems

    if (!fatfs.begin(&flash)) {
      errorMsg("needt to format flash");
      return false;
    }
#

This is for the on-board Flash, but assume it is similar for the SDCard version?

grizzled atlas
#

That dosent seem to work but found this command that does: SPI.setClockDivider(SPI_CLOCK_DIV2); Just trying each divider value

#

Changing this value crashes the M4

#

Just seen this on Google SPI.beginTransaction(SPISettings(20000000, MSBFIRST, SPI_MODE0))

#

I am going to call it there for tonight as it is 3am. Thank you very much. I will let you know if I get any further.

obtuse spruce
#

night

sour chasm
#

General Arduino question. I have a robot using 6xDC motors, 4x servos, and 1x stepper. The core code works great on a Mega 2560. But I'm trying to add a secondary Nano to run a Neopixel and Audio FX animation. The Nano runs great as well, thanks to help from the Adafruit forum. My problem is implementing the i2c protocol.

When I add wire.h and associated code to the Mega, suddenly the servos start twitching randomly and violently. The code is pretty long, so before I post it, is anyone aware of conflicts between servo.h and wire.h? I've seen some comments suggesting there's an issue with how they handle interrupts, but I'm not savvy enough to fully comprehend it.

vivid rock
#

It could be.
AFAIK, servo library uses interrupts to drive servos; i2c also uses interrupts, and it coudl be that one kind of interrupts gets in the way of another.

However, I wouldn't expect it to be a severe problem.

Can you test it by removing Nano for now and instead attaching some i2c sensor to Mega and using i2c to read data from it say once a second?

#

Another option is trying to use UART (aka Serial) interface for communication between Mega and Nano instead of i2c. In my experience it is less finicky than i2c. (Of course, the drawback is that serial only works between 2 devices, rather than being a bus to which you can connect many, but in your case it seems to be sufficient.)

vestal nebula
#

Quick question for y'all. Do I need to use the EN pin on a regulator or can i just leave it alone? I do not need any shutdown features, just whenever it is plugged into power, it turns on, and shuts down when unplugged. The regulator in question is the LM2776

sour chasm
pliant scaffold
#

Hey guys! Can anyone help me? Please! Basically I'm noob for Arduino I got a project where I need to make a motion sensor Cam I found a project (yes we can use other peoples projects) but I would like to use a PIR sensor instead of a sonar sensor so it doesn't detect unnecessary movement how can I swap the sensors?
And could you help me with the code so it would work with the PIR sensor?
I will just copy the code here since it isn't too long.
Code:
#define pingTrig 6
#define pingEcho 7

int cameratrigger = 2 ;
int led = 3 ;
void setup()
{Serial.begin(9600);
pinMode(pingTrig, OUTPUT);
pinMode(pingEcho, INPUT);
delay(200);
pinMode(led, OUTPUT);
pinMode(cameratrigger, OUTPUT);

}

void loop()
{
long duration, inches, cm;

digitalWrite(pingTrig, LOW);
delayMicroseconds(2);
digitalWrite(pingTrig, HIGH);
delayMicroseconds(10);
digitalWrite(pingTrig, LOW);

duration = pulseIn(pingEcho, HIGH);

cm = duration / 29 / 2;

Serial.print("-->");Serial.println(cm);
if(cm < 30 ){
digitalWrite(cameratrigger,HIGH);
digitalWrite(led,HIGH);
delay(200);
digitalWrite(cameratrigger,LOW);
digitalWrite(led,LOW);
delay(200);}}

livid osprey
pine bramble
#

On the featherwing RP2040, are all the GPIO pins capable of dectecting a button grounding them? I have 16 buttons I want to interface with them and want to avoid using an io expander or diodes.

#

Which ones will not work with simple HIGH LOW checks?

pine bramble
safe shell
pine bramble
#

oh perfect, thanks for confirming!

safe shell
#

you can prove it to yourself by setting each one up as input pullup and verify the change from grounding

formal onyx
#

Im looking at the arduino Uno reference schematic, and it appears that they have both a resonator and a crystal hooked up to both the atmega8 and atmega8u2. But looking at my (genuine) Arduino Uno, im only seeing a single resonator and a single crystal on the board, not two of each as the reference schematic suggests. Am I just missing it or is the schematic just saying you have the option of either resonator or crystal?

north stream
formal onyx
stable forge
# formal onyx Am I misinterpreting the symbols? Is the bottom maybe an expanded view of the bl...

I don't see a difference in the symbols. The reference design schematic you uploaded seems to me to be out of date: it uses an older choice for the USB microcontroller, for instance. The Arduino R3 link I gave is more recent, and the ATMEGA parts it references are on the current board. Perhaps the reference design is including alternative parts -- I don't know, but it does not reflect the current board as shipped.

#

Practically speaking, a resonator can be used in place of a crystal, usually for cost reasons, but is less accurate and stable.

formal onyx
stable forge
elder hare
#

how do i tell all my projects in PlatformIO to store / pull libs from the global lib folder?

astral swift
#

Hey everyone. I'm having some trouble with the programming of my (either micropython or arduino board) I've purchased several and written some test code for both) for an IR blaster project for an assistive technology user. What would be the best way for me to seek advice? Should I be posting my progress in a github repo or something? I've never received significant assistance with writing code but would love to see this being done with some collaboration. I've been planning on using this with an arduino nano or raspberry pi pico. I also purchased an seeeduino XIAO to play with but will probably stick with the pico for cost. What I'm planning on doing is basically to replicate the features of this device which appears as though it is no longer commercially made:

The way it works is you press a button/switch (plugged in with a 3.5mm aux jack, which is standard practice in the community for assistive tech for people with disabilities) and it begins scanning through each function, you press the button again, and it blasts the IR code that was already programmed in. Programming it is done with a sliding switch to "train" mode, although to make this easier I will probably just hard-code each device initially and make that programming function a secondary priority as I work in the building with the intended users. If this was to be an open source project I would be very excited to see ways to expand the usage to increase the range of functions and maybe add up to three buttons or so to the design.

I'm just not a programmer at my core, I work in healthcare and tinker with this stuff.

north stream
# astral swift \

Sounds like a straightforward enough project, the code shouldn't be very complex (there are libraries available for sending IR code), just a loop and some counters. What sort of advice are you looking for?

astral swift
#

Basically if I uploaded stuff to a github would people be willing to send feedback?

#

My other issue is that I was having issues with the actual IR code stuff, the libraries seem both very well put together and also just difficult for me personally to use due to my skill level. I managed to build a one button device that sent power on/power off (same command) for samsung TVs

#

it worked on my samsung in my OT lab but not in the resident's room. Also worked at home on my wife's samsung.

#

Just feeling like maybe I bit off more than I can chew, also just trying to learn how to write better/cleaner code.

north stream
#

It's hard to get response like that on github, few people have the time, skill, and motivation to go through someone else's entire code base and review it. I understand your frustration, it's hard to see the way forward when you're just starting out.

obtuse spruce
#

@astral swift - if you have question about a dozen lines or so - just post them here (use the ```C++ syntax to post them) and ask. If you want a quick review of your whole sketch, and it's not too long (<300 lines?) just put up on github (or a gist if a single file and that's easier) - and then ask here for some help.

#

It helps if you have a specific question or thing you want help with. But for shorter sketches someone (me, say?) might be willing to look it all over with commentary.

astral swift
#

yeah, I definitely understand, debugging your own code is tough enough, I guess I was mostly asking how to ask a question. my code is short. I'll start with a question on how to avoid tons of if statements however. Switch/Case isn't ideal either but I guess my issue is because I want to run through multiple states "Power on off/channel up/channel down/vol up/vol down/mute" and then have the entire thing loop

stark bridge
obtuse spruce
#

@astral swift Seems like from your description, what you want is a data structure: A list of items, where each item has a name (text? audio file?) and the IR sequence. Then your code need only loop over this list, presenting each one - and stopping when the user hits the button. IN this way your code isn't dependent on your data set.

#

If you want - go ahead and show us the version you have with if statements and just 2 or 3 items. I'll re-write it for you as a data structure enumeration.

#

Oh, is this C++ or Python?

#

(I can do either)

dusk parcel
#

test

#

Hi everyone, I'm working on the Matrix Portal AnimatedGIF project and am having troubles finding documentation on how to control the LED panels brightness. Does anyone have anything they could point me to to help out?

safe shell
#

I'm not sure if there is an overall brightness control, but you can scale the color values up (brighter) or down (dimmer)

dusk parcel
#

So this is where I'm starting to get lost. It seems the gamma values need to be changed for each GIF and that will play into the brightness that the LED panel eventually displays?

safe shell
#

that's exactly right, gamma maps to a curve that attempts to adjust the image in a way that makes sense for our perception

#

although the guide says 0.4 will get you pretty good results for most images

dusk parcel
#

ok cool, I'll start to look towards that as a point of reference. This is my first real project in this area so it's all pretty new for me

dusk parcel
#

bruh this works and I read over it so long ago somehow but didn't do it for some reason. Thanks a bunch ❤️ @safe shell

pastel pivot
#

Sarah way with an Arduino to read old EPROM chips

north stream
# pastel pivot Sarah way with an Arduino to read old EPROM chips

It's not too tough, basically you supply the right power voltages, drive the address and control (RAS, CAS, strobe, RE, etc.) with GPIO pins and read the data with other GPIO pins. Most chips are fairly flexible on timing. There's some nice sample code here: https://forum.arduino.cc/t/reading-obsolete-roms/295879

obtuse spruce
#

Anyone know if there is a way in Arduino to find out the size of the program at runtime? On a SAM D21 I'm using the left over flash for another purpose and right now I'm just using an estimate of the program size (based on upload data)-- but it would be nice at runtime to know for certain I'm not going to overrun the program

cedar mountain
#

The typical way to do this would be to add an "end of flash" variable to the linker script whose address the code can inspect at runtime. There may be one of these already in the build setup which you can reference.

#

You could also explicitly add a reserved section of flash for your extra data, so the linker would complain at compile time if there wasn't enough room for everything.

obtuse spruce
#

good ideas all… but will require i move on from building via arduino (in VSC)… which i should, i suppose… just so convenient as it is.

obtuse spruce
#

yay:

/* Symbols exported from linker script */
extern uint32_t __etext ;
#

pointer to end of .text segment

#

already in the linker script for my board (and all Adafruit boards it looks like)

gloomy sandal
#

hey, i need help fast, i have this code in a bilibrary but the arduino ide shows this error message when compiling

#

#ifdef CUSTOM_BOOTSCREEN_ANIMATED_FRAME_TIME

// Each Frame has its own custom duration
const boot_frame_t custom_bootscreen_animation[] PROGMEM = {
{ custom_start_bmp, 2000 };
{ custom_start_bmp1, 300 };
{ custom_start_bmp2, 300 };
{ custom_start_bmp3, 300 };
{ custom_start_bmp4, 300 };
{ custom_start_bmp5, 300 };
{ custom_start_bmp6, 3000 };
{ custom_start_bmp5, 300 };
{ custom_start_bmp4, 300 };
{ custom_start_bmp3, 300 };
{ custom_start_bmp2, 300 };
{ custom_start_bmp1, 300 };
{ custom_start_bmp0, 1000 };
{ custom_start_bmp7, 300 };
{ custom_start_bmp8, 300 },
{ custom_start_bmp9, 300 };
{ custom_start_bmp10, 300 };
{ custom_start_bmp11, 300 };
{ custom_start_bmp12, 300 };
{ custom_start_bmp13, 3000 };
{ custom_start_bmp12, 300 };
{ custom_start_bmp11, 300 };
{ custom_start_bmp10, 300 };
{ custom_start_bmp9, 300 };
{ custom_start_bmp8, 300 };
{ custom_start_bmp7, 300 };
{ custom_start_bmp0, 500 }
};

#

error: expected unqualified-id before '{' token
{ custom_start_bmp1, 300 };

gloomy sandal
obtuse spruce
#

those semicolons should be commas

gloomy sandal
#

i have also tried with commas but get the same error message

obtuse spruce
#

wellllll then we're going to have to see the definition of boot_frame_t

gloomy sandal
#

but where do I find these

#

ok all good i put a ; too much. oops my fault, but thanks for the help anyway 🙂

signal geyser
#

Hey, I was wondering if anyone could help me out? I'm trying to get the clock, data, and latch pins of an NES controller mapped up and the button presses to be correctly mapped to an xinput or dinput device readable on PC

#

I'm using an SAMD21 micro controller

obtuse spruce
#

so let's see if I understand - you have two controllers: (1) NES controller, and (2) and x/dinput controller. Controller (2) is connected to your PC and works as expected... you want to wire both controllers to a MCU so that when you use controller (1) it acts like controller (2)?

signal geyser
#

no, I have on controller, an NES controller.. the power, ground, latch, data, and clock wires are soldered to a SAMD21 board.. I am just trying to get a code to convert the data from the controller into a recognizable USB controller

obtuse spruce
#

aha - do you have a spec or reference for the NES controller's protocol?

signal geyser
#

basically a NES to USB controller adapter

#

the NES controller uses a latch chip which outputs an 8-bit signal, each bit corresponds to each of the 8 buttons

#

i've found sample scripts to translate that into something useable by arduino but not sure where to go from there

#

this device can use the TinyUSB stack, not sure if that's relevant, although the sample scripts won't compile for it

obtuse spruce
#

do those scripts include the code to toggle the clock and latch lines to read the bits - or just the 8-bit to USB controller conversion?

signal geyser
#

they seem to contain the code to handle the clock and latch pins, they don't seem to do any conversion to a USB controller though

obtuse spruce
#

okay - so I guess the first thing I'd do is get that working and just use Serial.print() to display what you read and decode. This won't get it working as a controller on the PC - but will let you focus on the first part of the project: reading and decoding the controller.

#

THEN you can focus on the PC controller side.

#

The TinyUSB stack will let you use the SAMD21 board as a HID device, so it can be like a keyboard or mouse. I'm guessing (but don't know) if standard PC controllers are basically keyboard style inputs over USB

signal geyser
#

I have one script that claims to do what I need it to do.. but compiling always results in the error "joystick was not declared in this scope"

#

if I attempt to include the joystick library, then I get this error "exit status 1
expected unqualified-id before '.' token"

obtuse spruce
#

sadly - I'm about to run out the door now - BUT - you should post links to that script and the library you're using for joystick... and the line the error is on.... perhaps someone here can look at that and see

signal geyser
#

I found a script that outputs to the serial monitor.. tested it with the serial monitor and confirmed the 8-bits of data are corresponding correctly with the buttons being pressed, turning from a 1 to a 0

#

so, the arduino is reading the button presses correctly.. it's just a matter of converting that into something the PC will recognize as a controller

#

fantastic.. seems my wiring was correct and didn't fall apart upon assembly

#

and it is reading each button in the correct position in the 8 bits of data

signal geyser
#

I guess to simplify.. 8 bit shift register to joystick buttons probably using the joystick library

solemn cliff
#

with tinyUSB you can also have a custom descriptor and pass as a controller. I don't know of good resources for how to do that, I only know the Circuitpython gamepad example.

signal geyser
#

yeah.. I just have no idea to map the shift register data to button presses for a tinyusb, or other kind of arduino joystick

solemn cliff
#

you are able to identify when the A button is pressed by reading the shift register right ?

signal geyser
#

yup

solemn cliff
#

what I would do, is look at examples for tinyUSB, try to set one up for keyboard first to see if I can get it to work, in the main code I would have the button A of the NES cause pressing the A key on the keyboard, up press up arrow, etc. then look for the USB controller example

signal geyser
#

i believe that's the 8th of 8 bits

#

albeit.. all bits are 1, and switch to 0 when pressed.. backwards I think

signal geyser
#

seems a big problem I am running into is none of the joystick libraries seem to want to compile on the Seeeduino Xiao

signal geyser
#

aah.. i got it to work.. finally.. seems to be reading as a Seee controller for now, but all buttons work correctly

verbal rain
#

When I try to use a rotary encoder with the Adafruit Circuitplayground Express board, whenever I include the CircuitPlayground.begin(); line in the setup() function, the encoder stops reading the rotation properly, what would be the issue with this library? Is there any workaround to this? The encoder reads properly until that line is added in the code

// Rotary Encoder Inputs
#define CLK 9
#define DT 6
#include <Adafruit_CircuitPlayground.h>
#include <Wire.h>
int counter = 0;
int currentStateCLK;
int lastStateCLK;
String currentDir ="";

void setup() {
  
  // Set encoder pins as inputs
  pinMode(CLK,INPUT);
  pinMode(DT,INPUT);

  // Setup Serial Monitor
  Serial.begin(9600);
//  CircuitPlayground.begin(); //this line breaks encoder
//   Read the initial state of CLK
  lastStateCLK = digitalRead(CLK);
}

void loop() {
  
  // Read the current state of CLK
  currentStateCLK = digitalRead(CLK);
 
  // If last and current state of CLK are different, then pulse occurred
  // React to only 1 state change to avoid double count
  if (currentStateCLK != lastStateCLK  && currentStateCLK == 1){
    // If the DT state is different than the CLK state then
    // the encoder is rotating CCW so decrement
    if (digitalRead(DT) != currentStateCLK) {
      counter --;
      currentDir ="CCW";
    } else {
      // Encoder is rotating CW so increment
      counter ++;
      currentDir ="CW";
    }

    Serial.print("Direction: ");
    Serial.print(currentDir);
    Serial.print(" | Counter: ");
    Serial.println(counter);
  }

  // Remember last CLK state
  lastStateCLK = currentStateCLK;

  // Put in a slight delay to help debounce the reading
  delay(1);
}
north stream
quartz furnace
#

New product Adafruit ESP32-S2 TFT Feather

Any ETA on the learn guide ? Specifically for pin outs and Arduino examples for TFT ? Much appreciated @silk scaffold Thanks 🙏🏻

safe shell
quartz furnace
wet crystal
#

Im not sure, this channel might be the best to ask. I just found an old analog keypad phone in my house. Did some googleing and tried to figure out stuff, but just found this video here https://youtu.be/KcvgQ9eWKDU

I just tried the same method by hooking the red wire to 5v and the other to analog input and tried to read something, but I had no success, besides the arduino detecs if it phone is hung or picked up. I post photo of the phone, can anyone help me a bit maybe?

My idea was to use the phone a small smarthome controller

machina eX präsentiert:
Ein altes Post- Telefon (Impulswahl) wird abgenommen mit einem Arduino Uno und so zum interaktiven Spielzeug. Zum Nachbasteln und rekombinieren. Präsentiert von Philip Steimel.

Arduino Code:
Komplett: http://www.philipsteimel.de/Impulswahl.zip
Schritt 1: http://www.philipsteimel.de/Telefon_Schritt_Eins.ino
Schritt 2: htt...

▶ Play video
north stream
#

Normal phone circuit voltage is 48VDC, and the ringing signal is normally 100-200VAC at 20Hz.

livid osprey
#

The buttons may be sending DTMF tones over the audio line, meaning an analog input alone may have some difficulties reading the buttons without FFT capabilities or something. If there’s a tone/pulse switch, pulse is slower, but much easier to read from an arduino.

#

Otherwise, you may also open up the insides and modify the circuitry to isolate the row and col connections and use as a 3x4 keypad that way?

north stream
#

DTMF decoder chips (MC145436, HT9170, MT8870, etc.) exist, but are somewhat obscure.

wet crystal
#

I know they usually operate at higher voltages, just thought a lower would be okay, as the guy in the video also just used 5v

north stream
#

Worth a try

gloomy sandal
#

Quick question, SDA and SCL are for I2C, and RX and TX are for SPI, right.

solemn cliff
#

though SPI usually uses MISO/MOSI, DI/DO, or other, it's a very loose standard

#

with RX and TX standing for receive and transmit, that's super generic after all 😉

gloomy sandal
#

I want to connect an arduino with an esp8266 by using Rx and txt and everything works just finde but I don’t know how to name this connection 😅

solemn cliff
#

that would be UART or just "serial"

gloomy sandal
#

Ahhh perfekt thx ✌️☺️

north stream
#

Well, they're all "serial", but RX/TX is usually asynchronous serial, which is what you want.

wet crystal
north stream
#

A buzzer makes a pretty poor speaker, but if it's all you have...

wet crystal
#

I have speakers, but im pretty sure the phone wouldnt have enough power to drive a speaker 😄

#

Or could I wire it to an AUX cable and hook that up to an amplifier

north stream
#

I suspect you'd get something out of a speaker. Maybe use a capacitor to couple it, so the DC powering the phone doesn't go to the speaker.

wet crystal
#

Where should I add the capacitor

#

Is that shematic right?

calm thicket
#

@inland gorge Hi

I am having great fun with your Mozzi code - many thanks

Your code works fine on a Seeeduino Xiao but i cannot seem to be able to get it to compile under the Arduino IDE 1.8.15 ( Portable )

Did you have to make any changes to the .H files in the Mozzi library as the errors i am getting seem to point in that direction

If you got the time , any pointers & help would be appreciated

Regards

inland gorge
calm thicket
# inland gorge Hi, what are the errors you're seeing? And I'm a bit confused. You say it's work...

so so sorry forgot to give you all the relevant info....

Let me try again....

@calm thicket
@inland gorge Hi I am having great fun with your Mozzi code - many thanks Your code works fine on a Seeeduino Xiao but i cannot seem to be able to get it to compile FOR RASPBERRY PI PICO under the Arduino IDE 1.8.15 ( Portable ) Did you have to make any changes to the .H files in the Mozzi library as the errors i am getting seem to point in that direction If you got the time , any pointers & help would be appreciated Regards (edited)

inland gorge
calm thicket
cobalt relic
#

I have a project where I am using the Feather Huzzah ESP32 and I can't plug the battery in the the JST plug due to having a small enclosure. I think the issue is easy to solve, but I just want to make sure I understand the documentation correctly before I blow a board. 😄

I think I can just solder a short wire with a female connection to the board itself to allow additional clearance. The positive wire would connect to BAR and the negative would connect to GND.

cedar mountain
sullen delta
#

I think I just burned the MC in this duino (shorted high digital pin) can't upload anything I'm getting programmer not responding error tried with other PC's still the same LEDs seems to be working the same is it really from the chip just to make sure?

#

(theres also little black spot in the chip its probably gone lol imma replace it)

cobalt relic
north stream
sullen delta
#

too late changed the MC but now I get (avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00) with the old error

#

lemme change da serial chip too thanks

bright shale
#

Am I allowed to post a small code for some Arduino help?

odd fjord
leaden dew
#

Hi all, Happy new year! I've drawn up this quick wire/circuit drawing and was wondering how I would go about coding a program that only turned on the motor when the soil sensor read dry soil? Any help would be great!

#

I've got the example program for the sensor, but still a bit new to coding; not sure how to make a loop to check the soil level then to do something about it

fervent verge
pallid grail
#

@leaden walrus If you're around, I could use an assist.

leaden walrus
#

sure. watup?

pallid grail
#

Trying to load Blink sketch onto the TFT Feather ESP. It's not cooperating. If I put it in the bootloader, it straight up can't find any board on that port. If I leave it running CircuitPython, it fails like this: ```Sketch uses 219774 bytes (16%) of program storage space. Maximum is 1310720 bytes.
Global variables use 17940 bytes (5%) of dynamic memory, leaving 309740 bytes for local variables. Maximum is 327680 bytes.
esptool.py v3.1
Serial port /dev/cu.usbmodemC7FD1A5970841
Connecting......................................____An error occurred while uploading the sketch
_

A fatal error occurred: Failed to connect to ESP32-S2: Timed out waiting for packet header```

#

And I can see on the display that it entered the REPL and typed a lot of U

#

It reset at least once trying to load it, but restarted into CP, and entered the REPL and did that.

#

I'm not sure what else to try.

leaden walrus
#

this is the new feather?

pallid grail
#

Yeah

leaden walrus
#

what are you doing for bootloader mode?

pallid grail
#

Double-tap reset, enters the bootloader. Shows the "drag something here" image on the display, and mounts the FTHRS2BOOT drive.

leaden walrus
#

and no com port at that point?

pallid grail
#

Apparently not.

#

Checking one more time.

leaden walrus
#

try the ROM bootloader. hold boot button while pressing rst.

pallid grail
#

Oh right.... obviously.

#

There it is.

#

Completely forgot about the ROM bootloader.

leaden walrus
#

hopefully can upload sketch to that

pallid grail
#

There it goes.

#

It's acting like it is.

#

hmm.

#

I had to manually reset, but it worked.

#
ERROR: ESP32-S2FH32 chip was placed into download mode using GPIO0.
esptool.py can not exit the download mode over USB. To run the app, reset the chip manually.
To suppress this error, set --after option to 'no_reset'.
To suppress this error, set --after option to 'no_reset'.```
leaden walrus
#

yah. that's like that sometimes.

pallid grail
#

Good enough. Need to ask Limor if I'm supposed to add all of that to the guide, or assume it'll work for other folks.

#

Thanks so much.

leaden walrus
#

sure. np!

gilded swift
#

I always have to manually reset after writing to the ESP32-S2

pallid grail
#

I didn't when I reloaded Blink on top of an already existing Arduino sketch.

gilded swift
#

I’ve tried using soft_reset with esptool but it doesn’t work

#

But I’m usually loading a fresh ESP32-S2

solemn cliff
#

I believe you need the ROM bootloader for the first sketch, then Arduino will install its bootloader that can upload on its own without pressing buttons

pallid grail
#

It's a CircuitPython problem.

#

CP won't let it enter the bootloader properly if it's loaded. Apparently.

#

It loads fine if it's already running Arduino. Obvs.

solemn cliff
#

yeah you erase the Arduino bootloader when installing CP

#

I think that's what's going on

supple turret
north stream
supple turret
#

Bunnies are militant little ||censored||...
When they are determined, they will chew it.

north stream
#

Bunnies are why aluminum and steel conduit were invented...

livid osprey
#

I thought it was rats, but that's kinda the same thing, huh.

supple turret
livid osprey
supple turret
#

Pretty much none. 😂

livid osprey
#

I think PVC was more appropriate as a bunny countermeasure, so don't take that too seriously LOL

#

In truth, metal conduit originated from the repurposing of older gas pipe systems as an easy way to run wire through a house. Though modern electrical codes forbid it today for seemingly obvious reasons, our purpose-built metal conduits were essentially a modern take on that.

gloomy sandal
#

hey, can someone tell me what component this is? so i know what it does but i don't know what component to put on the pcb for it.

stable forge
#

That is an on-board jumper, normally open. You can close it with solder.

cedar mountain
#

It's just formed from pads on the board, so there's no component needed.

stable forge
#

example of three in a row

gloomy sandal
#

but why is it in the schematic when i can connect it with solder. i have an Arduino MEGA in front of me right now and i can't find these jumpers.

#

because then i can simply leave out these jumpers, can't i?

stable forge
gloomy sandal
#

ahhh there, i only searched on my fake MEGA and there are none, there are some on my original one

stable forge
#

check whether it is normally closed or open. There may be a zero-ohm resistor there

supple turret
#

3rd parties don't always follow schematics. 🤣

gloomy sandal
#

yes i should have guessed that xD thanks anyway 🙂

stable forge
#

I did a bit of websearching of reset-en arduino mega and it's not clear to me whether it's normally shorted or not.

gloomy sandal
#

on my mega it's open

cedar mountain
#

It's not clear to me what RESET-EN would actually do, since it's connected on both sides of the jumper to the same RESET signal.

cedar mountain
#

Maybe just a convenient pad to manually ground the RESET line with a wire?

stable forge
#
#

etc

#

oh, that is a different jumper which is in the upper right on your schematic

#

I'm not sure where the 1-2 jumper is; I don't have one to check

livid osprey
livid osprey
# stable forge I'm not sure where the 1-2 jumper is; I don't have one to check

@gloomy sandal It looks like it's on the back of the board, though there seems to be soldermask over it for whatever reason, at least on my R3. I believe that it's meant to provide a means of connecting/disconnecting USB ground to the MCU, something which isn't likely to be used outside of some very particular noise control...

#

Not sure if you can see it clearly, but it’s the two rectangles right on the edge of that large ground plane.

#

...I think.

gloomy sandal
#

An ATMEGA82U-AU is the same as an ATMEGA8U2-MU, only the package is different, right?

#

*i mean the footprint is different not the package

leaden walrus
#

seems like

gloomy sandal
#

but i can use an atmega8u2-au instead of an aumega8u2-mu, right?

median mica
#

Can someone help me with this code? I am using an Uno to open and close three window blinds using stepper motors. The code listens for a button to be pressed and opens the blinds and marks the time in millis. Then the same button is pressed again and the blinds close and the time is marked again. Then some basic math is done and the cycle repeats itself daily. The code as it stands works great but now I would like to be able to independently open and close the blinds with push of a button while still observing the timed cycle that was mentioned previously. So, my first step is getting rid of the use of delay in the second half of the code. This is where I'm having trouble. So, i started with examples, I have two events (close-open, open-close) wth two intervals. My problem is that the first interval, from millis examples, happens every 1 second then the second event happens 5 seconds. The pattern I want is (close-open) happens at 1 second, then doesn't happen again until after the second event (open-close). Attached is my code.

#

This is the example code I'm working from:

#

"`/* Two "independant" timed events */
const long eventTime_1_LDR = 1000; //in ms
const long eventTime_2_temp = 5000; //in ms

/* When did they start the race? */
unsigned long previousTime_1 = 0;
unsigned long previousTime_2 = 0;

void setup() {
Serial.begin(9600);
}

void loop() {
/* Updates frequently */
unsigned long currentTime = millis();

/* This is my event_1 /
if ( currentTime - previousTime_1 >= eventTime_1) {
Serial.println("Event 2");
/
Update the timing for the next event*/
previousTime_1 = currentTime;
}

/* This is my event_2 */

if ( currentTime - previousTime_2 >= eventTime_2) {
Serial.println("Event 2");
/* Update the timing for the next event*/
previousTime_2 = currentTime;
}
}`"

#
obtuse spruce
#

When I want to do multiple timed things, I use this pattern:

unsigned long nextEvent1 = 0;
unsigned long nextEvent2 = 0;
  // using 0 here to mean no next time... 

void loop() {
  auto now = millis();

  if (nextEvent1 && now >= nextEvent1) {
    // do event 1 here
    // compute next event 1 time, via one of these lines:
    nextEvent1 = 0;               // no scheduled event for now
    nextEvent1 += 2000;           // every 2 seconds
    nextEvent1 = now + 2000;      // 2 seconds from now
  }

  // same for event 2 here
}
#

In your case, I think I'd code this like

livid osprey
#

It might also be useful to have the status of the blinds be saved as a separate flag, so you can enforce an open command to only run if the blinds are closed and vice versa.

obtuse spruce
#
unsigned long openInterval = 1000;    // blinds stay open for 1s
unsigned long closeInterval = 5000;   // blinds stay closed for 5s

unsigned long nextOpenTime = 1;      // start by opening
unsigned long nextCloseTime = 0;

void loop() {
  auto now = millis();

  if (nextOpenTime && now >= nextOpenTime) {
    nextOpenTime = 0;
    nextCloseTime = now + openInterval;
    openBlnds();
  }
  if (nextCloseTime && now >= nextCloseTime) {
    nextCloseTime = 0;
    nextOpenTime = now + closeInterval;
    closeBlinds();
  }

  // do other tasks here!
}
#

Essentially, you keep two event time variables going, even though only one of them is "set" (non-zero) at a time. When one event goes off, it "schedules" (by setting the variable) the next time of the other event.

#

(side note: If your project will be on for more than 49 days, you need to be aware that millis() will "roll around" it is possible for the code above to get "stuck" with a very high next event time, and now having rolled back around to near zero.... I can explain how to handle this, if you need... but gums up the code, and most projects don't remain on for 49+ days!)

#

@livid osprey - good suggestion. I'd do it like so:

bool blindsAreOpen = false;

void openBlinds() {
  if (blindsAreOpen) return;
  blindsAreOpen = true;
  // run the motors, open the blinds, let in the light
}
void closeBlinds() {
  if (!blindsAreOpen) return;
  blindsAreOpen = false;
  // close the blinds, the sun, it burns....
}
#

Aim here is to keep the logic of managing the blinds out of the code that is managing time.

livid osprey
#

@median mica Hopefully these snippets of code help. Thanks @obtuse spruce!

median mica
#

Thanks @obtuse spruce and also @livid osprey I read thru your snippets, trying to digest them. I’ll rework my code and see how it goes and let you know. @livid osprey flags are key! I nearly broke some of $$ blinds when the motors tried to open open blinds.

agile finch
livid osprey
#

The guide is from 2013 it seems, so this modification may be a bit more complex than originally designed for...

signal geyser
#

Hey, can one of y'all help me get a code to work on an ESP32?.. I'm just trying to read a 6 button Genesis controller into the serial console

safe shell
#

best to post your code (use the "+" sign to the left, for compactness, or link elsewhere, unless it's short)

signal geyser
#

i got a link to a sample code I use

#

or I am trying to get to work

#

I replaced the pins in that code with the correct pins my controller is connected to.. I get this error "Genesis:64:22: error: 'amp' was not declared in this scope
for (int i = 0; i &lt; sizeof(inputMap) / sizeof(input); i++)
"

safe shell
#

looks like something tried to encode for html

#

< got converted to &amp;lt;

solemn cliff
#

like twice, &amp;lt; --> &lt; --> <

safe shell
#

cut-and-pasted through several URLs or web editors or something

#

fix it directly in your Arduino IDE, back to <

signal geyser
#

so &lt; to < or to <<?

safe shell
#

I assume it's a less-than comparison (<)

signal geyser
#

I found a version of the script that was untainted

#

now I just need to figure out how to actually use this device since the Arduino IDE won't connect, and I do have the correct board selected

#

it's a D32, won't upload

safe shell
#

hold down boot/GPIO0 while pressing reset?

signal geyser
#

yup, tried that

#

i have GPI 0 grounded, and tried with and without reset, nothing

#

i might just scrap this board.. it's becoming too much of a hassle to deal with.. I think it's a very poor design

safe shell
#

and then unground GPIO0? the usual sequence is: press and hold GPIO0, press and release Reset, finally release GPIO0

signal geyser
#

I'll try it later, but if I really have to go through that dance whenever I want to try out a different script then I'm going to be inclined not to use it

livid osprey
signal geyser
#

yeah.. I should learn how to use micropython or circuit python

livid osprey
#

Circuitpython isn't available for ESP32, unfortunately. That would be the easiest option for developing a gamepad IMO, but you'd have to change your hardware to something compatible.

signal geyser
#

I have an RP2040 device as well

livid osprey
#

Micropython isn't as easy to switch between hardware with, but the ESP32 port is pretty convenient, especially if you pick up something like Mu that helps facilitate the initial setup for you...

#

RP2040 is nice, works well with everything, and shouldn't give you really any trouble compared to an ESP32.

#

What kind of error is your Arduino IDE giving you when you try to connect?

signal geyser
#

something about headers.. so it's just not going into the correct mode and I don't feel like hooking it back up again to look

livid osprey
#

Well, if you ever find the motivation to try again, you can post the errors from the Arduino IDE console and we'll help figure out what's going on.

signal geyser
#

I will, ty.. I need to find some code that actually does what I need it to do first before I try to figure out how to flash the ESP32

gloomy sandal
#

hey,
does anyone here know anything about marlin 2.0?

livid osprey
gloomy sandal
#

Okay 🙂 I would like to do a board configuartion in marlin with EEEB, but I can't, does anyone know how I can add a third heater?

livid osprey
#

Hm, I do see all the motion configs for up to 7 extruders, but none of the heaters...

livid osprey
thorn bronze
#

I’m looking for some help with an adafruit sfx board and an arduino mega. Anyone got some time to assist?

livid osprey
thorn bronze
#

Thanks so much Hem. Here’s a pic of the device I’m using. I’ve worked with it before on another project and it took a ton of tinkering to get it to work in serial mode. This one is a new one with a new Arduino Mega. The documentation from adafruit is for an uno. It recommends pins 4,5,6. From past experience and other forums, I see the mega needs to use RX and TX on 17 and 16. It seems RST can go to any pin. I’m using 22. Right now I’m just trying to get the test software that comes in the library to work. Copying the code below. I’ve specified softwareserial1 to work with RX and TX 1 on the Mega. That took some time to figure out in my last project. I have VIN connected to 5V, ground to ground and UG to ground to put it in UART mode. When I do all this I get the red and green lights on but the board won’t talk to the arduino. The serial monitor is supposed to give me a bunch of commands. But it just says adafruit sound board not found.

#

Here’s the code: /*
  Menu driven control of a sound board over UART.
  Commands for playing by # or by name (full 11-char name)
  Hard reset and List files (when not playing audio)
  Vol + and - (only when not playing audio)
  Pause, unpause, quit playing (when playing audio)
  Current play time, and bytes remaining & total bytes (when playing audio)

Connect UG to ground to have the sound board boot into UART mode
*/

#include <SoftwareSerial.h>
#include "Adafruit_Soundboard.h"

// Choose any two pins that can be used with SoftwareSerial to RX & TX
#define SFX_TX 16
#define SFX_RX 17

// Connect to the RST pin on the Sound Board
#define SFX_RST 22

// You can also monitor the ACT pin for when audio is playing!

// we'll be using software serial
SoftwareSerial ss = SoftwareSerial(SFX_TX, SFX_RX);

// pass the software serial to Adafruit_soundboard, the second
// argument is the debug port (not used really) and the third
// arg is the reset pin
// Adafruit_Soundboard sfx = Adafruit_Soundboard(&ss, NULL, SFX_RST);
// can also try hardware serial with
Adafruit_Soundboard sfx = Adafruit_Soundboard(&Serial2, NULL, SFX_RST);

void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit Sound Board!");
 
  // softwareserial at 9600 baud
  ss.begin(9600);
  // can also do Serial1.begin(9600)

if (!sfx.reset()) {
    Serial.println("Not found");
    while (1);
  }
  Serial.println("SFX board found");
}

void loop() {
  flushInput();
 
  Serial.println(F("What would you like to do?"));
  Serial.println(F("[r] - reset"));
  Serial.println(F("[+] - Vol +"));
  Serial.println(F("[-] - Vol -"));
  Serial.println(F("[L] - List files"));
  Serial.println(F("[P] - play by file name"));
  Serial.println(F("[#] - play by file number"));
  Serial.println(F("[=] - pause playing"));
  Serial.println(F("[>] - unpause playing"));
  Serial.println(F("[q] - stop playing"));
  Serial.println(F("[t] - playtime status"));
  Serial.println(

#

Well I put in the first 2000 character of the code. The rest is just the standard code from the library.

obtuse spruce
#

Also for here start the code with a line of ```c++ and end with a line ``` - which will format it nicely and make it more readable by us (you can edit your code above to do that) -

trail swallow
north stream
idle nymph
#

Hello! I am an electronics newbie and after learning a little bit about them I decided to buy an Arduino board, and I've made a few little projects :) However, I am having trouble with this one. It's supposed to light up LEDs in relation to how many letters a word has. It works but I'm not satisfied with my method (a lot of conditional statements). How do I make it prettier and more efficient?

#
#include <Arduino.h>

int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;
int led6 = 7;

void chosenWord(String word) {
    if (word.length() == 6) {
      digitalWrite(led1, HIGH);
      digitalWrite(led2, HIGH);
      digitalWrite(led3, HIGH);
      digitalWrite(led4, HIGH);
      digitalWrite(led5, HIGH);
      digitalWrite(led6, HIGH);
    }

    if (word.length() == 5) {
      digitalWrite(led1, HIGH);
      digitalWrite(led2, HIGH);
      digitalWrite(led3, HIGH);
      digitalWrite(led4, HIGH);
      digitalWrite(led5, HIGH);
    }

    if (word.length() == 4) {
      digitalWrite(led1, HIGH);
      digitalWrite(led2, HIGH);
      digitalWrite(led3, HIGH);
      digitalWrite(led4, HIGH);
    }

    if (word.length() == 3) {
      digitalWrite(led1, HIGH);
      digitalWrite(led2, HIGH);
      digitalWrite(led3, HIGH);
    }

    if (word.length() == 2) {
      digitalWrite(led1, HIGH);
      digitalWrite(led2, HIGH);
    }

    if (word.length() == 1) {
      digitalWrite(led1, HIGH);
    }
}

void setup() {
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
}

void loop() {
  chosenWord("Hello");
}
stable forge
#

not tested

#

might be off by 1

elder hare
#

Question, all my ESP32 are running a WebSocketsServer and i use a Qt App i made to connect to them! but some of them take a LONG time to connect :S now some of the ESP32 are running 8 led strips on 8 pins and some less and some even only 2 or 1!

would it be better to run the websocketserver on a own Thread?'

idle nymph
#
void change(String word) {
  int how_many = word.length();
  for (int i = 0; i <= how_many - 1; i++) {
    digitalWrite(led_pins[i], HIGH);

    if (how_many >= 7) {
      digitalWrite(led_pins[i], HIGH);
      delay(500);
      digitalWrite(led_pins[i], LOW);
      delay(500);
    }
  }
}
cedar mountain
#

You'll want to watch out for the case of having more letters than LEDs. Right now your code would read off the end of the LED array.

thorn bronze
#

This is maybe the issue @north stream. Thanks for the advice. I haven’t used hardware serial before. Is this just a matter of getting rid of all the software serial code and just specifying rx and tx as the rx1 and tx1 pins on the mega? Or do I need some other code to make it all work?

#

Maybe this answers the question: // can also try hardware serial with
Adafruit_Soundboard sfx = Adafruit_Soundboard(&Serial1, NULL, SFX_RST);

fathom summit
#

‘>>’ is the binary right shift operator

livid osprey
lapis meteor
#

HELP HELP

#
int ra; //random
int dv; // delay
int pin; //actual pin 

void setup() {
  Serial.begin(9600);
  pinMode(13,OUTPUT);
  delay(1000);
  pinMode(8, OUTPUT);
  delay(1000);
  pinMode(7, OUTPUT);
  delay(1000);
  pin = 13;
  
}

void loop() {
  ra = random(4);
  if (ra==3){
    digitalWrite(pin,HIGH);
    delay(random(5000));
    digitalWrite(pin,LOW); 
    delay(random(120));
    pin = 8;
    ra = random(5);
  }
  if (ra==2){
    digitalWrite(pin,HIGH);
    delay(random(5000));
    digitalWrite(pin,LOW); 
    delay(random(120));
    pin = 7;
    ra = random(5);
  }
}```
is an arduino uno 3
#

im extremely bad at physics

#

I am trying to make lighting pattern

faint raft
#

what do you have connected to the Uno?

lapis meteor
#

bulbs

faint raft
#

Can you show a picture of what your setup is?