#help-with-arduino
1 messages · Page 103 of 1
Something like this?
#ifndef LED_BUILTIN
#define LED_BUILTIN PIN_LED
#endif
That should catch that case, but might fail if PIN_LED also isn't defined
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.
I've also confirmed that it does have a 3V regulator on-board, FWIW
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
try this library - it worked well for me: https://github.com/olikraus/u8g2/wiki
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?
by praying
seriously, i dont know. They kinda worked, but half the screen was garbage
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
just fyi - you can edit previous message to fix code markup
thanks
just tried this and still found nothing
https://www.instructables.com/ESP8266-I2C-PORT-and-Address-Scanner/
ESP8266: I2C PORT and Address Scanner: Here I present the i2c_port_address_scanner.ino sketch for the ESP8266. The i2c_port_address_scanner.ino will not only discover the address of your I2C device but also the PORT numbers to which SLA and SLC are connected.For a newbie adding an I2C de…
What I2C device(s) do you have hooked up, and how are they wired? Do they have pullup resistors, for example?
device is si7021, no resistors
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.
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
A couple of one-cent resistors would be easier... 😅
I have no component supply close and dont wish to order just a couple xistors
resistors
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.
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?
Normally terminators will be like 50 ohm or something, right? That's way too much for I2C.
@cedar mountain, thank you for your advice
this is what I mean @cedar mountain
https://www.adafruit.com/product/4756
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.
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.
@leaden walrus I have a nomenclature question when you're around. Please ping when you're available, if you would be so kind.
@pallid grail hey. what's up.
@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.
Ok thank you, that's what I went with, but wasn't certain.
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?
Hey
So
I have this project
Which uses naruto handsigns to open a solenoid lock
So
My code is done
For now
glove_transmitter .ino.txt
the_safe_receiver.ino.txt
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
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?
From the Arduino's perspective, the only thing it knows about is the pin 6 connection to the first Neopixel, and how many Neopixels it needs to control.
I might connect both MCUs over UART, that way the non-solenoid MCU can send a message to the solenoid MCU.
And level shift if the two MCUs are running at different voltages.
If you are using 2 MCUs, that is.
Since this is more than just a simple question, you may get more traction by posting this in a new topic on (yet another place!) https://forums.adafruit.com. A focused topic there is an easier place to get help with a more involved project, like yours. Here on discord, things scroll off the top pretty quickly.
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.
The baseline might be offset to account for letters like "g" and "y" that descend a couple of pixels lower, and would use the y=0 row.
Thanks I was in school
@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
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.
Hello!
Drivers/devices
Hey
I have one student who bought a Adafruit NeoSlider I2C QT Slide Potentiometer (https://www.adafruit.com/product/5295) and we are getting a hard time trying to make it work
Our family of I2C-friendly user interface elements grows by one with this new product that makes it plug-n-play-easy to add a 75mm long slide potentiometer to any microcontroller or ...
Did anyone tried it? I know that is i2c, I was trying the i2c scanner with no luck
I am actually a begginer so I have basically zero knowledge help me through
It isn't just off set a couple of pixels, though. With .setCursor(0,0), lines of text can be shifted upwards and entirely off the display.
In any case, I would argue that it shouldn't be shifted it up at all.
I've literally only been using fonts included with the Adafruit_GFX library.
They still count as "new" fonts rendered from a baseline cursor, IIRC. Classic fonts would be like the Serif and Sans fonts.
Yeah, those are still considered "new" fonts, as characters have variable sizes as opposed to the fixed rectangles the classic fonts use.
Despite being included in the library, they behave like that of a custom font, and should be treated as such.
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
IF you could link the tutorial you're following, that would be a good start.
Yeah sure, I wasnt sure if I was allowed https://www.youtube.com/watch?v=2qI5G1pq2ZU
Okay, so the potentiometer has no code so we can ignore that.
ah ye thats probably why it worked lol
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?
I am not sure tbh, there is only one port and that stays when I unplug and replug it
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.
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.
And the cable works with your other Arduino?
What board are you using?
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)
Well, that sounds promising. Can you try programming the Arduino with that cable?
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?
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.
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?
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.
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)
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.
ah ok, thank you
In this project's case, each row only ever has one wire and one pin, so matching them up should be easy.
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?
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?
I think it'll only show up during reset or somesuch?
I did get it to work
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);
}```
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.
@livid osprey That was it. Thanks so much. I was getting mixed up with the positions.
it is the pre-qwiic si7021 Ada board
@livid osprey I get no difference using default pins
I have 4.7k pull ups on whatever pin I use
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
would this be better suited for #help-with-audio ?
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.
That is, in fact, exactly how I did this, using one output for vertical and one for horizontal.
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.)
Nevermind, I figured it out (hopefully)
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.
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.
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?
It sounds like the data is originally integer types, and if you divide by integer 100, you'll have an integer answer, which then gets assigned to the floating-point variable without the fraction. If you divide by 100.0 instead, it'll force the compiler to use floating-point arithmetic for everything.
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?
I drew my font using this http://xlr8.at/8x8hexbin/
what format do you need the font in?
I am assuming as a bitmap array or similar, not an actual font file like pcf?
@faint raft whatever format the library can handle, though the smaller the better.
smaller files size, that is
probably easiest with the bitmap array then
I just want a fized with font where the 1 is teh same width as everythign else
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.
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. 😦
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...
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!
Do you have separate chip select (CS) lines going to each module?
Alas, it will too, it doesn't use a gated level shifter.
You could add a tri-state gate in front of the MISO lead and drive it with CS to get around that
Yes I have
I dont really understand that to be honest. Do you mean I can make my current sd card reader work? Is that difficult to do?
It will too = the adafruit board will interfere with the nrf24 module too?
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
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!
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
I have some 74HC125 level shifter laying around. I think those would work too right? Thanks a lot for all the help!
Yes, those should work too.
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?
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.
@north stream how does that malloc() thing work in this instance?
i just read that malloc is not good to use on arduino because of fragmention
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.
@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);
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.
make what a class?
@north stream so instead of a struct make it a class?
I thought you already had a class (since you referred to a "constructor")
this is the class yes with a struct inside
@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);
I just want to let you know I got it to work, thanks a lot 🙂
this -> https://www.toptal.com/developers/hastebin/hutevagoco.cpp draws (X amounts) of random squares on my matrix in different sizes and moves them randomly! as of now they overlap eachother! is it possible to make them "bump" into eachother?
The code already has them bouncing off the edge of the screen, so you would want to modify the code so it's checking for collisions between pairs of squares in addition to between squares and the screen borders.
question, is that not hard todo? collision detecting
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.
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!
You can easily respond to typing sent over the serial port from the computer (with Serial.read(), for example), but that's generally not sensitive to how long keys are held down.
My idea is to use arduino as a keyboard to controller converter by soldering the aruino output pins to the controller pads, but maybe there is another way
im working with a Nano 33 BLE. am i able to use mbed libraries such as BufferedSoftSerial with arduino?
Gotcha. For something like that, you'd probably want some simple software on the PC side which is sending key-down and key-up events to the Arduino instead of just typing into the serial monitor.
does anyone know if fadeToBlackBy function in fastLED could that be done with the ESP32-VirtualMatrixPanel-I2S-DMA ?
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
Given the y * x math, I'd assume that the 0,0 origin is actually in the bottom right of the panel in the photo. So maybe the panel is upside down versus what you think it should be?
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
Your prior code has (v >> 8) + 127, which offsets by 127, so that's probably why it's starting on green.
i just removed the + 127 and now it starts with
yea
but it`s still displaying the palette twice :S
for some reason
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.
i just based it off of my WS2812B FastLED script
ColorFromPalette(_ledsettings._palette_current, Index * 255 / _NumLeds);
What's your panel width and height?
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?
i tried but didn`t work
@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?
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...
it only showed 1 solid color (red)
Which one did? All of them?
yea :S
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.
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
Can you post your code that was last known working on the BNO055?
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;
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.
yeah i think at that,i look the two shoud output in radians/s
wait what the library unified sensor can change something?
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?
the bno055 from adafruit
for the lsm6 the lib is also from adafruit
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.
Are you sure it's a PWM fan? Normally the three-pin connectors just have a tach feedback, but you need four-pin for the PWM speed control.
https://github.com/adafruit/Adafruit_NeoPixel does not compile for ESP8266 boards.
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
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)
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
if you leave tio open to the port, it blocks esptool
tio?
it’s always closed. Unless having MU open is blocking it
But my devices don’t show up to use MU REPL
I don't think so. what errors are you getting?
“Device not configured”
we are in #help-with-arduino btw
We can switch to circuitpython help
let's do
how do i make my analog 5w and ground give power out?
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
Can you provide more context?
fixed it
New here.
Is there any decent tutorial for hooking up QTPy M0 to a SD card breakout? I'm pulling my hair out, haha.
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 🙂
is there a recommended tutorial for having one arduino board access sensors on a second arduino board?
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!
The PCA9685 itself has an upper voltage limit of 5.5V, so you should not exceed that when powering Vcc. V+, on the other hand, is simply a bus to distribute power for the servos, so you should use that to supply the servo 6V power.
It should be fairly straightforward if you're just connecting the hardware SPI pins. Care to share what you're stuck on?
Something like this would be a good start, perhaps? https://www.teachmemicro.com/microcontroller-serial-communication/
Oh I see. I read the limit for the Vcc and thought it was for V+. Thank you!
Which POV staff are you struggling with?
@livid osprey i made it myself with ws2812 led strips
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.
this is the original graphics.h
when i try with this it works but when i convert new gif's its not working
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?
@livid osprey yes it uploads succesfully no memory error or any other errors. i am using df robot bluno beetle
Do you get any errors during runtime?
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
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.
154x72 is 11kB of memory. The 328P only has 2kB of SRAM available, so there's no way it could load that image ino memory.
uhm so what do u suggest me to make pov with this blunobeetle ? smallew pics ?
smaller i mean
Definitely start with smaller images. I would not exceed 72x16, and for an initial test I'd try to go even smaller.
@livid osprey thank you so much when i solve this image problem i will have couple questions too 🙂
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
@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.
Possible? not sure when it was written nor which version of Python it was written for. Have you tried both Python2 and Python3?
let me try
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.
Try building the code from https://forum.sparkfun.com/viewtopic.php?t=42454 and see if that works.
@livid osprey pff my brain is frozen its kinda late here tomorrow i will continue thanks for help cya !
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
I'm looking for some help with adafruit's nr52 support for arduino. Is this a good place to ask ?
Yep, just fine.
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
that's pretty elderly, so it may be restricted to quite an old version of itself or pyserial or other dependencies
how can i find out ? It's only one Mint major release old, dont really want to upgrade
3.5.2 is from 2016
is that the system-installed Python?
what is your mint version?
it's still 3 though, right ? they wouldnt introduce an incompatibiilty on a minor release number would they ?
18.3
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.
Mint 18 is not listed in their repo list now: http://packages.linuxmint.com/
does nrfutil has a published minimum version ?
what is the version you have?
i mean for python
but It crashed when running adafruit-nrfutil --version so unsure
what is the backtrace?
if big, upload here wihth "+" to the left or a pad
not a big deal
50 lines is fine
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})."
)
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
thanks. more usewd to irc, and my favourite etherpads all seem to have died
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
gonna be messy, because it's being run by the arduino download script
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
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.
or
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.
@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'
you'll need to set up a venv or virtualenv and reinstall (via pip3) the dependencies inside the venv
ok. I tried just changing the interpreter path in the script. Not enough ?
no, because the pip3 installs are specific to a version
ok ta
e.g installed in ~/.local/lib/python3.8/...
so I would need to rerun the adafruit library install inside the venv in order to get the nordic sdk in the right place ?
i think you can just do pip3 install adafruit-nrfutil inside the venv. It will pick up the dependencies it needs.
yay! works 🙂
Great!
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?
@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):
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
I think you'd just want to draw the head as a few-pixel bitmap sprite yourself, bright in the center and dimmer around the edge.
@cedar mountain yea that is what im trying atm
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????
Arduino adds forward declarations to "help" you, which causes issues
ah! thanks that’s it exactly!
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
got it.. it’s making forward decls for everything in *.ino
meh!
so just move all your decls to before setup and loop, I guess
wish you could turn that off - trying to make a one file sketch to go with a bug report
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.
yeah.. i’m usually a many small files guy… but i wanted a single file for this bug… ah well…
You can have a single .cpp and what do you care if an empty .ino file litters the directory? ;)
for me, i don’t just for posting “here this sketch shows the bug”
I get that, sure.
The bug is arduino.cc though. ;)
They just had to mess with something standard.
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
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.
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
Looks like this is where the dummy handler is taken care of: https://github.com/arduino/ArduinoCore-samd/blob/master/bootloaders/mzero/Bootloader_D21/src/ASF/sam0/utils/cmsis/samd21/source/gcc/startup_samd21.c
that's it. thanks
well, I don't think that's part of the adafruit arduino samd core
ok, found it. Same idea but not ASF
https://github.com/adafruit/ArduinoCore-samd/blob/master/cores/arduino/cortex_handlers.c
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
more info would help. what all hardware is being used? what code is being run?
Anyone awake?
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?
The SDCard will share the SCK, MISO and MOSI lines with the radio. It just needs a unique chip select
Okay thanks
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.
Is Arduino 2.0.0 going to a rough upgrade or easy?
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?
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
We use our fork to submit PR's against the philhower core. You could file an issue against our fork to bring it our attention, bring it up in the forums, etc.
initially i was going to ask about it in an issue on Adafruit's fork but issues aren't enabled on it and i figured i would ask in here before making an issue on the main philhower repo
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.
good point
@ me with the URL of the forum post and I'll see it gets some attention. Going to sleep now 🙂
alright thanks, checking over the board schematic and digging around in the board's pin definitions in the core's source now to make sure i'm not just crazy before i submit the post
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
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
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
@stable forge here's a link to that post detailing the issue with the QT Py RP2040 and the philhower Arduino core pin mappings https://forums.adafruit.com/viewtopic.php?f=25&t=186682
Hi I want to control current that goes to LED with AD5821, does anyone know how to do it? I couldnt understand the datasheet 😦
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.
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
@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;
}
If I may ask, what does the min(output, 0x3ff); do?
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
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?
it is defined in Arduino.h i believe
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?
I'm intrigued the chip manufacturer offers a device driver for it: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/regulator/ad5398.c?id=HEAD
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)
Can't comment on the code, but you can do multi-line code blocks with syntax highlighting with
```cpp
Code
```
I did😅
Oh. It showed up weird on my phone at first but it looks normal now
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
eagle eyes
debugging is the art of forgetting everything that you "know" as you read the code
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.
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
Where does ImageReturnCode come from?
because that's where the issue is at
Also, maybe try to follow this example first: https://www.waveshare.com/wiki/File:4inch_TFT_Touch_Shield_Code.7z
and then you branch out into the Adafruit code
This Exmaples work fine, I started with them and added there what I need.
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.
yup
But don't i need the ImageReturnCode to load the image and to check the size of it?
Ok my problem is still not fixed but I know now what I need to do.
I need to find a library which is a subclass Adafruit_SPITFT and works with my 3.5inch tft lcd shield from WaveShare (ILI9486).
I already tried a couple of libraries.
I have seen the driver and still got no clue how to use it on my system..
thank you for your advices 🙂 I still havent managed to make it work yet, and I am still evaluating the issue
Have you tried the Adafruit ones?
Yes, but there is no specific One for the ili 9486 display
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
It's probably a non-static function, so can only be called with an instance of the class, so instantiate one, then use that to call it.
Does the peripherals view when debugging in platformio actually work or is my code broken?
(feather m0 express trying to configure AC because reasons)
eh, I don't see what's wrong with my code either
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
I do understand this is the problem... but I can not figure out how to implement this suggestion.
I don't think a union can have an instance method like you've written for write()... at least not 1990's era c++
Huh, looks like that's changed
Looks like you're calling an instance method _write() of the parent class/struct/union without naming which one you're calling it on. You'll have to pass it in to write(), or make the instance global, or make that not an instance function
hi, is there a way to feed an arduino uno an unregulated 5V (like the usb input) without going through the usb port ?
not 5V
You should be able to power it by providing 5V on the 5V pin.
oh, thought the 5v was only output. Thats makes life easier
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?
If you want to test it - I'd wire it up to a CircuitPython enabled board as shown here: https://learn.adafruit.com/adafruit-airlift-breakout?view=all&gclid=CjwKCAiAzrWOBhBjEiwAq85QZ3UyB96v8qH60d2MKbrLzcMqqoE-UVqTrjsHFnoIscstglvsa6AeFxoCu2kQAvD_BwE#circuitpython-wifi
Then run that test code.
I think that page also has an Arduino based setup if you don't want to do Circuit Python
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
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?
https://www.adafruit.com/product/3885 Will this speaker work with an arduino nano? I am slightly newer to this magical world of electronics and originally was using this with a CPX in makecode.
Hey, have you heard the good news? With Adafruit STEMMA boards you can easily and safely plug sensors and devices together, like this Adafruit STEMMA Speaker - Plug and Play Audio Amplifier. ...
the adafruit tutorial doesn't mention anything about using it with arduino so i thought i would ask here
Yeah, should work fine, just choose the appropriate adapter cable
Is there a tutorial or library I could use?
I think you can just use the tone() call to make beeps https://www.arduino.cc/reference/en/language/functions/advanced-io/tone/
The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.
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?
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.
Oh ok! Thank you
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);
}
Looking at your code, I see you have the oled reset tied to 4. Most of the oled reset lines I know of are active low, meaning the voltage needs to be pulled to ground to register the reset signal. However, the built in button is intended to be active high, as one end is pulled up to 3v3, not gnd.
My advice would be to change the oled reset definition to a different pin, separate from the built in tact switches.
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.
Thank you so much, that was the issue
IT is a C++ compiler, after all, so theorectically you could pieces of boost.
This is really old, but maybe it still works, or check to see if there are forks that are more up to date: https://github.com/vancegroup/arduino-boost
also https://forum.arduino.cc/t/importing-boost-library/437150
Yeah - I'm a little worried about memory management on a microcontroller with boost - it seems like arduino already doesn't fully support C++ STL and boost is a big leap (its for audio applications which are already tricky even on a desktop with mmu)
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
Can someone tell me what these 6 pins are for? (The wires are there because a schematic I was using had them there)
I'm guessing they're an ISP port (typically a 2x3 header block) or a serial port (typically a 1x6 header block)
not clear what board that is, but some similar boards use it for SPI
Note: ISP uses SPI, so that port is often used to get SPI signals offboard
ah, did not know about ISP
It’s a 2x3
Is the thing that is inside a purple circle with a star next to it that thing?
I’m guessing yes?
looks that way... ICSP (in-circuit serial programming)
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
Should I just get one of these? https://www.adafruit.com/product/5333
It’s not too much bigger
These are useful for sharing out grounds: https://www.adafruit.com/product/874
There are also a variety of tiny breadboards available you can use to fan out connections https://www.adafruit.com/product/2463
I need something really tiny because this is for a cosplay with limited space and I am using the header pins and socket cables
The 4x4 breadboard is smaller than the snap-action connector and you can plug jumper wires straight into it.
Is there some sort of really small Y socket/header/jumper cable?
The other issue is that this is right by my face
The next step is rolling your own, either with wire nuts or cutting, soldering, and insulating (with, say, heat shrink tubing)
Could I theoretically cut and solder the jumper wires that I already have into a Y ?
Yup. I do that sort of thing a lot.
Ok
I have the stuff already anyways
Then I will be able to add that speaker to this project
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?
As opposed to what?
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
It might work, but it would just depend on the specs of the fan, in terms of required voltage and max current draw.
Ok will have to do some components research
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)
My Feather STM32F405 won't show up as a listed Serial Port in MacOS - am I missing someting?
If CircuitPython is not on the board, and you don't put it into boot mode, I don't think you'll see anything. STM chips have a built-in DFU bootloader you have to enable with a jumper: https://learn.adafruit.com/adafruit-stm32f405-feather-express/dfu-bootloader-details
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 😛
Well, if the Arduino program is running, it should show Serial port, but 🙂
Sorry, I didn't realize this was #help-with-arduino
answering things in four different channels
Thanks! A headache for another day I think haha
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"
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
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.
Well global ones 🙂 Defining them inside classes and structs in headers is fine depending on your coding style
Sure, I meant anything that actually instantiates a variable in memory.
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 😁
@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
@obtuse spruce Thank you I am not sure what the keyboard Featherwing uses I am looking into it now.
Oh that is interesting!
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
I have the V2 that I got from Pimoroni https://www.solder.party/docs/keyboard-featherwing/rev2/
Yeah the neopixel on the front uses D11
So there you have a conflict... though I'd think the SDCard would work no matter what and only the Coprocessor would fail
here's the pinout of the Co-Processor: https://learn.adafruit.com/adafruit-airlift-featherwing-esp32-wifi-co-processor-featherwing/pinouts
That's what I would have thought. Not sure how I will solve this. Funny thing I dont use the neopixel. Thank you.
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
Perfect! I'll give it a try.
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
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
That is one nicely designed FeatureWing, actually! I'm impressed
Its super nice.
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)
ok I just change the airlift pin in the code to 11?
ok, sorry I dont understand how the AirLift knows to use the D11 to stop conflicting?
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
Got it!
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
Doing it now. 😁
OK, neo pixel no longer works but the MicroSD card also does not work.
@obtuse spruce Thank you very much for trying to help me.
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?
No.
hrm.... we are all missing something here because there should be no problem with sharing those SPI lines
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?
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);
ok, ill try it now
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
yes
I just tried running standalone WiFi code only with the keyboard attached and it failed.
so to recap: M4+CoProcessor -> WiFi standalone works ; M4+Keyboard -> SDCard code works ; M4+CoProcessor+Keyboard -> neither WiFi standalone nor SDCard code work
Agreed.
(BTW how are you getting all three to attach? Feather double board? stacking headers?
Stacking headers. from keyboard, next layer is AirLift then M4 Express
should be fine.... power? from USB I assume?
yeah and or lipo
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
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
and it works with the keyboard feather on - whether on or off?
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.
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)
Agreed.
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 ?
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
yes cs=D9
Now - the only two things that should be different between display and SDcard is the CS line
Yes. Display uses 9 and sd uses 5
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);
Dont think so.
setting the SDCard to go slower? Maybe it is just too fast with all the load on the SPI lines?
Doing it now.
Cant get that command to work. I have put it after each module begin?
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?
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.
night
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.
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.)
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
In datasheet of lm2776 it says en pin should be connected to high to enable output
https://html.alldatasheet.com/html-pdf/804472/TI1/LM2776/171/3/LM2776.html
Well it's working now; I've been through multiple edits, but I suspect the problem was from a misplaced wire.endTransmission call, which left the line open too long.
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);}}
Rather than repurposing an ultrasonic sensor project, I would recommend starting from https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/ and using the code on the "Using a PIR w/Arduino" page.
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 all pins are digital-capable https://learn.adafruit.com/assets/107203
oh perfect, thanks for confirming!
you can prove it to yourself by setting each one up as input pullup and verify the change from grounding
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?
which schematic are you looking at? I am looking at https://content.arduino.cc/assets/UNO-TH_Rev3e_sch.pdf?_gl=1*152hq38*_ga*MjAxMzkyOTA1LjE2MTQzNTM5MTQ.*_ga_NEXN8H46L5*MTY0MTM1NTU3MS40Ni4xLjE2NDEzNTU1ODEuMA.. from the product page: https://store-usa.arduino.cc/products/arduino-uno-rev3/?selectedStore=us. I see one crystal on the ATMEGA16U2 and one on the '328.
Hm, im looking at this: https://www.arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf
I see a crystal, two padding capacitors, and a bias resistor.
Am I misinterpreting the symbols? Is the bottom maybe an expanded view of the blue part of the schematic?
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.
Hm okay, I'll reference the schematic you've linked then, thank you
The link URL is a mess, but it is a clear link off the current product page
how do i tell all my projects in PlatformIO to store / pull libs from the global lib folder?
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.
\
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?
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.
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.
@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.
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
switch/case in a loop is the classic implementation of a state machine in C. Assuming that when you talk about running through multiple states you are referring to a finite state machine.
@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)
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?
I'm not sure if there is an overall brightness control, but you can scale the color values up (brighter) or down (dimmer)
"GIFs played on the LED matrix may appear overly bright and washed-out. A different guide explains how to adjust for this" https://learn.adafruit.com/animated-gif-player-for-matrix-portal
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?
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
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
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
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
The Mega 2560 works great for reading odd-pinout ROMS. It has enough I/O pins to eliminate the need for additional latch ICs. I needed to read a 68766 EPROM from my 1980s vintage Radio Shack Color Computer, but my GQ-4X E/EEPROM burner wouldn’t handle it. This chip has a 24-pin non-JEDEC-standard pinout. By hooking up the digital I/O pins to th...
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
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.
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.
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)
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 };
error message when compiling
those semicolons should be commas
i have also tried with commas but get the same error message
wellllll then we're going to have to see the definition of boot_frame_t
but where do I find these
ok all good i put a ; too much. oops my fault, but thanks for the help anyway 🙂
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
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)?
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
aha - do you have a spec or reference for the NES controller's protocol?
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
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?
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
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
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"
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
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
I guess to simplify.. 8 bit shift register to joystick buttons probably using the joystick library
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.
yeah.. I just have no idea to map the shift register data to button presses for a tinyusb, or other kind of arduino joystick
you are able to identify when the A button is pressed by reading the shift register right ?
yup
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
i believe that's the 8th of 8 bits
albeit.. all bits are 1, and switch to 0 when pressed.. backwards I think
seems a big problem I am running into is none of the joystick libraries seem to want to compile on the Seeeduino Xiao
aah.. i got it to work.. finally.. seems to be reading as a Seee controller for now, but all buttons work correctly
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);
}
I'm guessing that the .begin() function resets the pin 6's mode when it enables capacitive touch. Perhaps make your pinMode() calls after .begin()?
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 🙏🏻
@quartz furnace it's a 240x135 ST7789 driver, you can see the pin assignments here (not sure where the Arduino file is, but this should help): https://github.com/adafruit/circuitpython/blob/main/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c looks like there is a power control pin to enable/disable power for I2C and TFT (not sure if it's active-high or active-low like the regular FS2 Feather), and a separate one for the NeoPixel (probably active-high)
Ahh nice 👌 find .. so GPIO@21
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...
Normal phone circuit voltage is 48VDC, and the ringing signal is normally 100-200VAC at 20Hz.
Picking up off-hook is a good first step. I did that a while back in a project to detect off-hook and interpret rotary dialing. https://www.youtube.com/watch?v=lRhTC_rIhR4
Interfacing a rotary dial phone with a microcontroller
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?
DTMF decoder chips (MC145436, HT9170, MT8870, etc.) exist, but are somewhat obscure.
So should I try to hook a speaker to the output and see ifs sending dtmf tones?
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
Worth a try
Quick question, SDA and SCL are for I2C, and RX and TX are for SPI, right.
RX and TX are usually for UART, but sometimes for SPI too
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 😉
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 😅
that would be UART or just "serial"
Ahhh perfekt thx ✌️☺️
Well, they're all "serial", but RX/TX is usually asynchronous serial, which is what you want.
Is a buzzer enough?
A buzzer makes a pretty poor speaker, but if it's all you have...
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
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.
@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
Hi, what are the errors you're seeing? And I'm a bit confused. You say it's working but you can't get it to compile on Arduino? These are Arduino sketches so I'm unclear what you mean.
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)
Ah! Mozzi does not officially support the RP2040 chip that's in the Pico. But there is a fork by pschatzman at https://github.com/pschatzmann/Mozzi that has preliminary support. Use that library instead of the sensorium one. You can see an example here, with notes in the comments: https://github.com/todbot/mozzi_experiments/blob/main/eighties_dystopia_rp2040/eighties_dystopia_rp2040.ino
ahh that explains it....
Will try again tomorrow as have to get some shuteye before work,,,
Really appreciate the help
Looking forward to annoying my neighbours with RP2040 dystopia as soon as possible
TTFN
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.
Yep, that should work. According to the schematic, those pins directly connect to the JST plug, so they should be completely equivalent.
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)
Awesome, that is what I thought, thanks for the help!
Could be the main chip is okay, and the USB-serial chip has died. I did like the ability to just swap the main chip in the old DIP socketed Arduinos.
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
Am I allowed to post a small code for some Arduino help?
Yes! see this post about code posting #welcome message
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
This guide is using circuit python but the basic ideas are the same: https://learn.adafruit.com/pet-bowl-water-level-sensing-with-the-funhouse-and-home-assistant
Perfect! Thank you!!
@leaden walrus If you're around, I could use an assist.
sure. watup?
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.
this is the new feather?
Yeah
what are you doing for bootloader mode?
Double-tap reset, enters the bootloader. Shows the "drag something here" image on the display, and mounts the FTHRS2BOOT drive.
and no com port at that point?
try the ROM bootloader. hold boot button while pressing rst.
hopefully can upload sketch to that
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'.```
yah. that's like that sometimes.
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.
sure. np!
I always have to manually reset after writing to the ESP32-S2
I didn't when I reloaded Blink on top of an already existing Arduino sketch.
I’ve tried using soft_reset with esptool but it doesn’t work
But I’m usually loading a fresh ESP32-S2
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
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.
yeah you erase the Arduino bootloader when installing CP
I think that's what's going on
I'd love to use something like that for the bunnies, but they would chew the wires. Lol
Still doable, you'd just need to protect the wires with conduit or have everything in a local enclosure.
Bunnies are militant little ||censored||...
When they are determined, they will chew it.
Bunnies are why aluminum and steel conduit were invented...
I thought it was rats, but that's kinda the same thing, huh.
Seems overkill, but... Probably good. Lol
Is it though? Name one flexible material that can withstand the teeth of a determined rabbit.
Pretty much none. 😂
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.
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.
That is an on-board jumper, normally open. You can close it with solder.
It's just formed from pads on the board, so there's no component needed.
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?
ahhh there, i only searched on my fake MEGA and there are none, there are some on my original one
check whether it is normally closed or open. There may be a zero-ohm resistor there
3rd parties don't always follow schematics. 🤣
yes i should have guessed that xD thanks anyway 🙂
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.
on my mega it's open
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.
Maybe just a convenient pad to manually ground the RESET line with a wire?
Hi i need to disable auto-reset when i connect with serial connection, First i tried with a 120 ohm resistor between 5V and "RESET" and that didnt work. Now i wonder how i should cut the trace, what should i use to do it? does any one have a picture where it´s done? And after i have disable the auto reset, how should i do when i need to uplo...
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
From the looks of it on the one I have, the reset trace runs directly between the pads, so the board file would show the pads directly over that reset line. Essentially it's closed by default, you would have to cut it to open it, and the pads are there in case you need to bridge it after it's been cut.
Ah, makes sense, thanks!
@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.
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
seems like
but i can use an atmega8u2-au instead of an aumega8u2-mu, right?
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.
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;
}
}`"
Have you ever wanted to do MULTIPLE timed events with Arduino? What about multiple CONCURRENT timed events? We’re “upping” our game with this lesson, so buckle in and hold on tight! The millis story so far This is part of a mini-series we’ve been publishing that’s all about using the Arduino millis function to…
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
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.
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.
@median mica Hopefully these snippets of code help. Thanks @obtuse spruce!
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.
helping someone with this, seems it no longer fits on a plain trinket: https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display/build?view=all#code
Seeing as the initial code was within 120 bytes of max capacity to begin with, it's highly likely that some updates to the libraries have pushed it over the edge. You may have to manually remove unused parts of libraries or revert to an older version to get it to fit...
The guide is from 2013 it seems, so this modification may be a bit more complex than originally designed for...
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
best to post your code (use the "+" sign to the left, for compactness, or link elsewhere, unless it's short)
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 < sizeof(inputMap) / sizeof(input); i++)
"
like twice, &lt; --> < --> <
cut-and-pasted through several URLs or web editors or something
fix it directly in your Arduino IDE, back to <
so < to < or to <<?
I assume it's a less-than comparison (<)
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
hold down boot/GPIO0 while pressing reset?
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
and then unground GPIO0? the usual sequence is: press and hold GPIO0, press and release Reset, finally release GPIO0
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
ESP32? You could consider MicroPython if Arduino is giving you trouble. Since it's an interpreted language, you can easily make modifications to code without having to reflash the board every time. Not sure if it has all the functionality you're looking for, but it might work better if you don't want to use esptool.py to reprogram it every time.
yeah.. I should learn how to use micropython or circuit python
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.
I have an RP2040 device as well
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?
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
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.
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
hey,
does anyone here know anything about marlin 2.0?
It is a 3d printer firmware. If you have a question regarding a technical difficulty, you should just start with that and see if anyone can help.
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?
Hm, I do see all the motion configs for up to 7 extruders, but none of the heaters...
What kind of controller are you using?
https://marlinfw.org/docs/hardware/boards.html offers information on modifying pinout definitions for boards, if that's what you're looking for.
I’m looking for some help with an adafruit sfx board and an arduino mega. Anyone got some time to assist?
Most of the guys here are kinda in and out between irl commitments, but if you have any issues you can’t seem to resolve, I recommend just leaving the issue here with as much information as possible (source code, error messages, etc) and someone will get to it in time.
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.
if you have large code - put it in https://gist.github.com/ or https://pastebin.com/ --- then just dump the link here
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) -
I see from the commit message in https://github.com/adafruit/Adafruit_VS1053_Library/commit/6e8899a855c70860ac56eb7727cf7bd013cf5b8f that it's a known problem that the ESP32-S2 crashes in Adafruit_VS1053_FilePlayer.begin(), but I see no issues filed to make it not crash. Any ideas as to whether it'd be sane for me to try to fix it?
You don't need to use software serial on a Mega, it has hardware serial Serial1 on pins 19 (RX) and 18 (TX), and Serial2 on pins 17 (RX) and 16 (TX).
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");
}
put the LED pin numbers in an array. Then you can write a loop to run through the pins and turn on however many you want:
const int NUM_LEDS = 6;
int led_pins[NUM_LEDS] = { 2, 3, 4, 5, 6, 7 };
void change(int how_many, bool state) {
for (int i = 0; i < NUM_LEDS; i++) {
digitalWrite(led_pins[i], i < how_many ? state : !state);
}
}
not tested
might be off by 1
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?'
Thanks! I rewrote it and I think it's more understandable now.
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);
}
}
}
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.
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);
In case you want to do something more challenging and closer to the bare metal of the AVR processor : I haven’t tested this, but I think you could make your code even shorter by connecting your LEDs to PORTB (assuming Arduino Uno) and, instead of using digitalWrite, directly writing to PORTB the value 1 >> word.length (after checking word length)
For more info, I found this tutorial: https://idyl.io/arduino/how-to/manipulate-arduino-ports
‘>>’ is the binary right shift operator
That, and make sure to uncomment Serial1.begin();
You may have to comment out your software serial references to avoid conflicting pin definitions.
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
what do you have connected to the Uno?
bulbs
Can you show a picture of what your setup is?