#help-with-arduino
1 messages · Page 63 of 1
So they should function the same doing it either way?
There are some subtle differences. For instance, &NORTH exists when it's a variable, but not when it's just a #define constant.
Does anyone have experience w/ the raw RFM 95 chip? Without the breakout board?
I wired a pair up to my nanos and tried to test a two way comms setup (one receiver and one transmitter). Transmitter works but it doesn't seem to receive- any thoughts?
Is there a limit to how long the wire can be from the arduino to the neopixel? 10 feet is ok? I want to control just 3 neopixels.
11:33
arduino ----->>>>>>3 feet of cable --->>>> neopixels
There is some sort of limit, but 10 feet should be fine.
In theory, but if you have a Pi already I find those + OpenOCD to be the better tool, most of those programmers I try are buggy
@stuck coral I got a PI Zero today (its painfully slow 😞) I installed OpenOCD by following this tutorial: https://learn.adafruit.com/programming-microcontrollers-using-openocd-on-raspberry-pi/compiling-openocd
however, when I got to the sudo openocd part I get an error:"sudo: openocd: command not found"
also in /usr/local/share I have no open ocd as ther is here: https://youtu.be/-EIaDxSIBYw?t=1108
Subscribe to Adafruit on YouTube: http://adafru.it/subscribe
Join our weekly Show & Tell on G+ Hangouts On Air: http://adafru.it/showtell
Watch our latest project videos: http://adafru.it/latest
New tutorials on the Adafruit Learnin...
I dont know if that could cause the issue
Sounds like the final sudo make install step might not have been run?
I think you are right!
Hi! I'm not much of a hardware guy, but I've got an Arduino 33 IOT and I'm trying to get it to work with a ring of 16 Neopixels (part 1463). I'm trying to adapt the simple sketch here for the nano R3: https://create.arduino.cc/projecthub/zanycadencedev/getting-started-with-arduino-and-neopixels-013360
I've changed PIN to 3 and # of LEDs to 16. This is my code:
https://gist.github.com/gallaugher/60c364943c22b5f4588ef289523b5276
I have soldered the wires in the neopixel ring yet. I thought I could just poke into the holes for the male-to-male jumper wires - GND, 5V, Digital In, and connect these to the 33 IOT's GND, 5V, and D3. I've got jumpers on the arduino. female to croc clip to wire clipping to see if I can get this simple sketch to work. Upload looks fine, but I'm getting nothing. Any advice on what I'm doing wrong? Should I solder the Neopixel ring GND, 5V, and Data in, then try clipping those to the croc clips? Thanks!
Before soldering it, you may have better luck putting the alligator clips directly onto the pads on the ring.
Sounds like the final
sudo make installstep might not have been run?
@cedar mountain I got a little further, but now it doesnt show any errors, but also doesnt display the target and its status.
The last thing it shows is Listening on port 4444 for telnet connections
Am I going a bit off topic for this section?
@north stream soldered it up since alligator clips didn't seem to be showing any results, but this doesn't seem to be working, either. Here's a pic of the setup now & a link to the gist: https://gist.github.com/gallaugher/60c364943c22b5f4588ef289523b5276
I wonder if you need a level shifter
@north stream I'm not sure what that means. Sorry - hw n00b...
I think (but I'm not sure, I don't have one) that the 33_IOT is a 3.3V board, and the neopixels operate on 5V logic: sometimes they'll work with 3.3V data, sometimes they won't.
However, there could also be some other problem (wrong type of pin or code set up wrong or something)
@north stream OK. I plugged into the 5V pin as shown here. Might that not be enough? https://content.arduino.cc/assets/Pinout-NANO33IoT_latest.png
Depends on how that board works. I'd hope it would be connected to 5V from the USB, but maybe not?
@north stream since this sketch only lights up one pixel, I switched to the 3.3v pin & it's now nicely flashing in RED, as the sketch would suggest it should. I know the spec says these rings are 5v rings. Is there a risk I might damage the board or the rings if I try to run this off of the 3.3v? And if this is a concern, how would I try to deal with the board apparently needing some change in the power other than what's going into the 5v pin?
It won't damage them, but there may not be enough voltage available to light the green/blue LEDs
I'm not sure the best way to deal with the 5V supply
The last thing it shows is Listening on port 4444 for telnet connections
@forest lark I can communicate with the board on telnet, but when I type at91samd chip-erase it says "chip erase started", but when typing at91samd bootloader it still shows the size of 131072 bytes
@stuck coral any ideas?
I'm just guessing here but I'd expect the same number of bytes: the storage is still there, just blank.
I did the atsame5 bootloader 0 command
now when typing atsame5 bootloader it says: "Bootloader protected in the first 0 bytes"
reset command gives a handler hardfault
it still never completed the chip-erase command
Both neopixel and red led are off now
can someone help me w programming my robot to walk
basically i want it to follow the semi circle then follow the line
and then go in a loop but for some reason the legs dont even move
also ik that there r stuff i can remove from the code but im j trying to b cautious
Looks like a piecewise approximation of an arc?
What part of the code is sending movement commands to the legs/motors?
basically thats an issue as well
cuz the servo library doesnt work in arduino pro ide
so i decided to make my own pwm
and it should be every 1 in the pwm is a degree
but its weird cuz it doesnt work for some reason
without further context, it looks like the given code is calculating stuff but never commands the servos to move
The PWM frequency has to be in the range the servos expect, and the pulse width (not the duty cycle) is the important bit, it should be around 1-2ms.
1-2ms?
the servo can move 255 degrees even tho it claims 270 (sort of got scammed ig)
and also for the servo movement i use this equation:
afaik it's typical for you to be able to turn the servo arm further than it can drive itself
it calculates the angle from the line
I figured there must be some sort of following step, since your code fragment didn't compute servo positions directly.
Yes, your xLR and yLR values looked like they needed some math
i did that slightly above so it moves along the x axis
and follows the curve
wait is pwm digitalwrite or analogwrite?(ples tell me its analog)
looks like analog from the docs
o thank god
When you said you made your own PWM, I figured you weren't using analogWrite()
what arduino is this on? make sure you're using pwm pins
its a mega
That isn't going to work, the pulse widths are all wrong
yeye ik its not a hardware issue cuz it worked fine when i used the servo library
wait what do u mean?
What I said above: the pulse width needs to be in the 1-2ms range.
pulse width or pwm frequency?
PWM frequency is fixed, it should be about 50Hz. Pulse width controls servo angle.
wait analogwrite is 0-255 right?
if this reference is correct, then the pwm frequency of arduino's pwm outputs is way too high https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/
The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.
Yes, analogWrite goes from 0-255, which gives 0 to 100% duty cycle.
Doing the math, with a 20ms timeslot, a 1-2ms pulse works out to a 5-10% duty cycle. So you can't use anywhere near the entire 0-255 range.
so if my servo goes to 255 degrees how do i move it to 255 degrees?
Set the pulse width to 2ms.
(more or less, some servos will want slightly more or less, like 1800µs)
wait i dont get it
whats the difference between the millisecond thing and a dutycycle
Duty cycle is how much of the time the signal is high. Always low is 0% duty cycle, and always high is 100% duty cycle.
If it's on half the time, that's 50% duty cycle. But (as I pointed out above), it isn't duty cycle the servo is paying attention to, it's pulse width.
AHhhhh i c
wait but how would i write the width?
can i j write analog write and then add the ms?
There are two ways: one way is just use the servo library, which does the math for you (and I think it uses a higher precision mode and takes care of setting the clock period correctly).
But you can do it with analogWrite() if you configure the frequency properly. Once the frequency is write, your servo range is 1ms (which is a 5% duty cycle, or an analogWrite() value of 13) to 2ms (which is a 10% duty cycle, or an analogWrite() value of 26).
So if you're using analogWrite, your servo range is around 13-26.
That only gives you 14 positions: not much accuracy, and you also have to write special registers to set the frequency to something the servo can understand. The servo library takes care of this, and gives finer grained control. You can do this too, but not with analogWrite(), which is a little limited for this use.
Here's a nice writeup on RC servo control signals https://www.pololu.com/blog/17/servo-control-interface-in-detail
You could, but why not just use the servo library?
wait u can use it without it?
Yes, the servo library lets you use microcontroller pins to control servos, you don't need the separate controller unless you need to run more servos at once.
i need to run 12 servos going in different directions at the same tiem would i need one of those or is 12 still ok?
o wait nop got it lmoa
The 12 channel board does come in handy for controlling a bunch of servos at once, like I did with this quadruped robot
o i should probs get that then
\effect_minmax.cpp:16:22: error: invalid use of member function (did you forget the '()' ?)
t = (((maximum - minimum) * t) + maximum + minimum) * 0.5;
any ideas how to fix?
What are maximum and minimum?
floats defined in the .h
i think they are the problem, i just tried with just 1 instead of them - it worked fine
(at least it compiled)
#ifndef effect_minmax_h_
#define effect_minmax_h_
#include "Arduino.h"
#include "AudioStream.h"
class AudioEffectMinmax: public AudioStream
{
public:
AudioEffectMinmax(void) : AudioStream(1, inputQueueArray) {}
void minimum(float minimum){}
void maximum(float maximum){}
virtual void update(void);
private:
audio_block_t *inputQueueArray[1];
};
#endif
^my .h
Why are they functions?
I'm making an object for an audio library
Yeah but this void minimum(float minimum){} doesn't make any sense.
It's a function named minimum that does not do anything or return any value.
Did you mean to write just float minimum; ?
im using an existing object as reference
and it uses functions for variables (idk how)
public:
AudioEffectFade(void)
: AudioStream(1, inputQueueArray), position(0xFFFFFFFF) {}
void fadeIn(uint32_t milliseconds) {
uint32_t samples = (uint32_t)(milliseconds * 441u + 5u) / 10u;
//Serial.printf("fadeIn, %u samples\n", samples);
fadeBegin(0xFFFFFFFFu / samples, 1);
}
void fadeOut(uint32_t milliseconds) {
uint32_t samples = (uint32_t)(milliseconds * 441u + 5u) / 10u;
//Serial.printf("fadeOut, %u samples\n", samples);
fadeBegin(0xFFFFFFFFu / samples, 0);
}
virtual void update(void);
It does not 😉
Anyway, if you change those lines to float minimum; and float maximum; then your code will compile.
they have to be inside a function with float parameter right tho?
that way it is accesible from the arduino sketch
class AudioEffectMinmax: public AudioStream
{
public:
AudioEffectMinmax(void) : AudioStream(1, inputQueueArray) {}
float minimum;
float maximum;
virtual void update(void);
private:
audio_block_t *inputQueueArray[1];
};
#endif
Although you probably want to do the following as well: AudioEffectMinmax(void) : AudioStream(1, inputQueueArray), minimum(0.0f), maximum(1.0f) or whatever, so that they have default values.
AudioEffectMinmax(void) : AudioStream(1, inputQueueArray) {}
void minimum(float minimumValue)
{
float minimum = float minimumValue;
}
void maximum(float maximumValue)
{
float maximum = float minimumValue;
}
The functions are called from arduino sketch when you want to change parameters - so this should work right?
No, but something like this will:
class AudioEffectMinmax: public AudioStream
{
public:
AudioEffectMinmax(void) : AudioStream(1, inputQueueArray), _minimum(0.0f), _maximum(1.0f) {}
void setMinimum(float minimum) { _minimum = minimum; }
void setMaximum(float maximum) { _maximum = maximum; }
float minumum() { return _minimum; }
float maximum() { return _maximum; }
virtual void update(void);
private:
audio_block_t *inputQueueArray[1];
float _minimum;
float _maximum;
};
Sorry, at work
@stuck coral Now a better time? 😬
Yes, it is
transport select swd
set CHIPNAME samd51g19a
source [find target/atsame5x.cfg]
bcm2835gpio_swd_nums 25 24
bcm2835gpio_trst_num 7
bcm2835gpio_srst_num 18
adapter srst delay 100
adapter srst pulse_width 100
init
targets
reset halt
#atsame5 chip-erase
atsame5 bootloader 0
# program bootloader-grandcentral_m4-v3.10.0.bin verify
flash write_image bootloader-grandcentral_m4-v3.10.0.bin
reset
shutdown```
This is my cfg file, it gives no errors, but doesnt seem to load the bootloader. It still says usb device not recognised when plugging the board in
Alright, gimmi a moment to check my old cfg file
when using the program function it gives errors and the computer doesnt even pick up that something has been plugged in
What do you mean?
Also, I think you need to swap the first line with source [find interface/raspberrypi2-native.cfg]
program bootloader-grandcentral_m4-v3.10.0.bin verify
instead of
flash write_image bootloader-grandcentral_m4-v3.10.0.bin
raspberrypi2-native.cvg for a PI Zero?
Could you copy whats in terminal and use formatting so I know what is output? And yes
Origonal Pi has a different pinout then all the other boards
Sorry, I was using the pi independantly on another screen, now my mouse and keyboard wont work all of the sudden
Hm, sounds like youre having a issue, either powring the pi or your wiring to the other board
You have a hardware issue you need to solve first
Hm, sounds like youre having a issue, either powring the pi or your wiring to the other board
it looks like it boots up fine, I re started it without the board connected too
Sounds like you might have not enough amperage going to your pi to me
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : JTAG and SWD modes enabled
Info : clock speed 2002 kHz
Info : SWD DPIDR 0x2ba01477
Info : atsamd51p20a.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for atsamd51p20a.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
Info : SAM MCU: SAMD51P20A (1024KB Flash, 256KB RAM)
shutdown command invoked
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections```
Sorry for the delay, here is what I get with the cfg I posted, but with the change in line 1
@stuck coral Can a bad usb cable cause bootloader problems? My cousin used my cable now to program his itsy bitsy and he had to double tap the reset button again...
It was also the cable I used when the GC stopped working
It can be, but if I remember right didnt I tell you to try another cable and you said you did
I did, the gc doesnt work on anything
Ah, so it caused the issue, yes that can happen
Even bad front USB on a desktop can cause it
Atleast we have a possible cause then
Not anymore, but for all M4 boards produced before a certain date
I did update his bootloaders though
Well he could just retap the reset button to upload new code right? The updated bootloader locked itself
right
Yours wasnt and the bad USB caused the transfer to overwrite the bootloader so you cant double tap the reset button
I see
Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : BCM2835 GPIO JTAG/SWD bitbang driver Info : JTAG and SWD modes enabled Info : clock speed 2002 kHz Info : SWD DPIDR 0x2ba01477 Info : atsamd51p20a.cpu: hardware has 6 breakpoints, 4 watchpoints Info : starting gdb server for atsamd51p20a.cpu on 3333 Info : Listening on port 3333 for gdb connections target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc Info : SAM MCU: SAMD51P20A (1024KB Flash, 256KB RAM) shutdown command invoked Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections```
@forest lark @stuck coral did you see this?
Yes, I dont see an issue with that output, does it still not work?
If not we can poke around the processor
Nope, neopixel is solid red and the "L" led rapidly fades in and out
how does one poke around?
and where?
😋
Make a new directory and cd into it, add this new cfg file in it-
source [find interface/raspberrypi-native.cfg]
transport select swd
set CHIPNAME samd51g19a
source [find target/atsame5x.cfg]
bcm2835gpio_swd_nums 25 24
bcm2835gpio_trst_num 7
bcm2835gpio_srst_num 18
adapter srst delay 100
adapter srst pulse_width 100
init
targets
reset halt
And open a second openssh session, you will need two
In one run openocd again with the new cfg file, the other type telnet localhost 4444
@stuck coral Im ready
Alright, post the output of openocd for me formatted?
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : JTAG and SWD modes enabled
Info : clock speed 2002 kHz
Info : SWD DPIDR 0x2ba01477
Info : atsamd51p20a.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for atsamd51p20a.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000574 msp: 0x2000dfe0
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
^[[AInfo : accepting 'telnet' connection on tcp/4444```
Great, output of telnet?
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
>```
Great, what prints when you type in telnet bootloader?
I got some errors when making a new directory so just used the openocd one and commented the unneeded lines out, hope thats ok
Sure, thats fine.
Ok, atsame5 chip-erase?
There are more steps, please just keep going
So next lets manually write the bin, flash write_image bootloader-grandcentral_m4-v3.10.0.bin
Then if I remember right, to verify use flash verify_bank 0 bootloader-grandcentral_m4-v3.10.0.bin 0x0
SAM MCU: SAMD51P20A (1024KB Flash, 256KB RAM)
wrote 16384 bytes from file bootloader-grandcentral_m4-v3.10.0.bin in 0.186678s (85.709 KiB/s)
>```
this is new!
read 16384 bytes from file bootloader-grandcentral_m4-v3.10.0.bin and flash bank 0 at offset 0x00000000 in 0.152210s (105.118 KiB/s)
contents match
>```
ready for usb test?
There you go, so now it's flashed for certain, yes
just unplug and test?
Sure
If it doesnt work, then it is a physical issue with the USB connection or the IC is damaged
If you dont see the neopixel go green, then the bootloader cannot enumerate a USB connection with the computer
Nope, neopixel is solid red and the "L" led rapidly fades in and out
@forest lark this still happens
Hm. strange. The only software component is the bootloader on the micros side and now thats flashed correctly
during some of my fiddling today the neopixel went green, but wasnt connected to usb, is that possible?
just connected to swd
Hm, it shouldnt do that. Lets try something
Could you write a arduino sketch that just prints to console something and flashes the LED?
ok
sorry, do you know if this boards led is on pin 13
nvm, I will just put an led somewhere
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(9, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Something");
digitalWrite(9, HIGH);
delay(500);
digitalWrite(9, LOW);
delay(500);
}```
something like this @stuck coral ?
Sure
So let me try to remember how arduino caches the files... you're running windows I presume?
yes, windows 10
Okay, well I think you can actually go to Sketch>Output Compiled binary and you can then see in your project a .bin file
can someone help me with getting my lcd screen to work, it is still doing this.
ok, did that
strange image format
#include <LiquidCrystal.h>
LiquidCrystal lcd(11, 10, A0, A1, A2, A3, A4);
oid setup()
{
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT); //LCD display
digitalWrite(A5, HIGH); //LCD display
lcd.begin(16,2);
}
@forest lark so if you can put that on the pi, and replace the bootloader on the metro with the sketch using the same process as reflashing the bootloader, and it doesnt show up as a COM port on your computer, I am at a loss
ya I airdropped it from my iphone so idk
ok, I will just need a few minutes to figure out how to do it and get back to you, thanks for your time, I really appreciate it!
Np, if it was in front of me then I could debug it further but for me to do it through discord it would take all day
So erase chip again?
Yes
teamviewer? 😆
Well you also have windows, I would need to adjuest how I do everything and I cannot spend my whole day doing that
I understand fully, I will let you know what happens
I am trying to upload the Blink Sketch to a Metro M4 Grand Central. It fails when trying to run the bossac cmd with this error: java.io.IOException: Cannot run program "REMOVE/bossac": error=2, No such file or directory.
Evidently, it is trying to run the bossac cmd with this path: REMOVE/bossac
How can I fix this? I am using the latest boards file from GitHub and the latest Arduino (1.8.13)
Have you installed both the Arduino SAMD boards package and the AdaFruit SAMD boards packages?
@unkempt radish what version is your bootloader?
2.0.0. will make you cry
@stuck coral The led does not even flash, neopixel and "L" led are off
Very interesting, is the LED on pin 9?
yes, I uploaded the sketch to a mega to test and it works fine
I put an external led on pin 9
Okay, then just reupload the bootloader. I dont really have another solution other then inspect the USB connections
Thanks, it is strange that the led doesnt flash though?
A bit, the sketches are able to run without a bootloader
is it possible to upload the bootloader and a sketch with openocd?
Yes, multiple ways, I would recommend making a single bin file
@north stream Yes I have, but I installed the Adafruit one first.
@forest lark I just installed it. It is 3.10.0
@stuck coral thanks again for all your help, I think I'm ready to give up for now.
Np, too bad about your board
I solved the problem. Within the arduno/tools/bossac folder, it was missing thi latest bossac (1.8.0-48-gb176eee). It was incuded with Seeduino packages, so I just copied it from there.
I just bought a adafruit metro mini 328 and it says I can code it with the Arduino IDE. I have plugged my board up to my computer but it will not recognize. The only method I found for getting it set up is to look under other devices but it is not showing under there either.
Try installing the Adafruit drivers (it's the first download on this guide https://learn.adafruit.com/adafruit-metro-mini/arduino-ide-usage). Once the device is recognized, you can program it as an Arduino Uno.
Okay thanks!
@fathom ibex that did not seem to work. I installed the drivers then unplugged and plugged the mini back into my computer and nothing happened
Does your board show up under ports in the IDE?
Also, make sure you did this:
When you run it, make sure to click that you want to install the SiLabs CP210x and FTDI chip drivers too!
I installed those with the link and the website says to select the arduino uno board and I did. it also does not show up under the ports in the IDE
oh, you will have to reboot too
nope still nothing. Am I just so dumb I can't see the obvious or could I have gotten a faulty board.
It shows on and the board LED is blinking so I know the power is working. My computer just doesn't see it. I am honestly confused
@glossy sierra what OS are you running?
10
it isn't a "power only" usb cable is it?
I don't believe so
Might be
It was one I had laying around. So instead of ordering a new one I started using this one
some chargers don't connect the data pins
I will go buy a new one tomorrow and see if that fixes it.
Okay thanks! Never would have though of this problem
If I head to Staples and look for a cord will it tell me if it will connect the data pins?
Or do i have to buy it and hope for the best or should I just buy one online and wait a few days?
i think they are usually marked "data type" or some such, i'll look at Staples quick...
I will go there tomorrow and see. Thanks for the help!
look for "Hi-Speed USB 2.0 Cable" or similar
Okay
It's late, I'm tired, and this is probably a really stupid question, but does a joystick button go LOW or HIGH when pressed?
Would this mean when pressed, or while not pressed? :
if (digitalRead(SW_pin) == LOW)
The short answer is that there's no standard... a random joystick might have buttons that work either way.
I have tried it as INPUT_PULLUP, and as just simply INPUT, and niether seem to be working, so the rest of my code is probably just too screwed up.
i made a led animation but whne i put batterys nothing seems to work
@tacit plaza if you measure the pin voltage, does it change when you push the button?
@pine bramble How many LEDs are you using?
need a bit more detail which type of LEDs, what board, what voltage...
single color red LEDs?
i did not put on 5v or 3.5 volts
single color red LEDs?
@reef ravine no
one green,2 blue,1 yellow,2white,1red
not rgb
do u want a photo of the circuit?
i did not put on 5v or 3.5 volts
@pine bramble ?
it's likely to need 3.3 or 5 volts
and it's an UNO?
yea
so it works on USB?
What voltage is your battery?
I don't see any resistors
9v
@pine bramble are the pins wired directly to the LEDs?
int LED1 = 13; int LED2 = 12; int LED3 = 11; int LED4 = 10; int LED5 = 9; int LED6 = 8; int LED7 = 7;
do you have any resistors?
ok, you may have had a dead battery, but you should have resistors in series with the LEDs
idk how to use resistor so
you may damage the pins or LEDs without them
idk how to use resistors
they limit current to a safe level, the striped object above is a resistor
but i have
resistor
and idk how to use them
my dad told me about ohms and stuff
not used any resistor
i didn't see any...
what time is it for u guys
UTC -5
uhm
It looked like one on the ground rail.
Ohh, nevermind. That's prubably just the end of a jumper.
Looked like a resistor on my big monitor from across the room.
@pine bramble take a look at https://create.arduino.cc/projecthub/glowascii/led-blinkies-arduino-basics-9a1bbb
you need resistors with LEDs
But yeah, @pine bramble , you should always use resistors on LEDs or you will burn them out super-fast.
use a 220 ohm in series with each LED
Most any of them would be better than none. For most things I just use a 220 ohm. For old school TTL circuits, I will sometimes use 420 ohm instead.
at least im happy about my code works...
the code works fine
@tacit plaza did you measure the pin voltage?
Not yet. Had to put it on hold.
Taking care of something time sensitive at the moment.
but I know my code is bad. Much of it was just guessing, based on what I know of other languages. Still very new to Arduino.
do something simple like just reading that pin and printing a 0 or 1, build from there
It's probably a simple oversight, or not knowing enough about code structure. I'll post a photo of the schematics I'm working with and spoiler of the code, after I finish this job.
What's "M"?
(M) = tiny vibrating motors. Their voltage range is good for anything under 6 volts, low power requirements, and enough internal resistance to use as-is. (Salvaged from old cell phones).
ok, for experimenting , using diodes across motors is best practice
the little phone vibrators will probably be ok
I use motor speed/directional controlers for anything larger.
Code, In parts due to character limits:
|| ```code
// Analog Joystick to 4X PWM output
// Arduino pin numbers
const int SW_pin = 2; // digital pin connected to joystick button
const int X_pin = A1; // analog pin connected to joystick X
const int Y_pin = A2; // analog pin connected to joystic Y
const int LEFT = 5; // digital pin for pwm output channel 1 LED
const int RIGHT = 6; // digital pin for pwm output channel 2 LED
const int UP = 10; // digital pin for pwm output channel 3 motor
const int DOWN = 11; // digital pin for pwm output channel 4 motor
const int stateLED1 = 3; // Mode 1 LED test indicator for future use of changing states of behavioral mode
const int stateLED2 = 4; // Mode 2 LED (described above)
int state;
void setup() {
pinMode(SW_pin, INPUT_PULLUP);
pinMode(X_pin, INPUT);
pinMode(Y_pin, INPUT);
pinMode(LEFT, OUTPUT);
pinMode(RIGHT, OUTPUT);
pinMode(UP, OUTPUT);
pinMode(DOWN, OUTPUT);
pinMode(stateLED1, OUTPUT);
pinMode(stateLED2, OUTPUT);
digitalWrite(LEFT, LOW);
digitalWrite(RIGHT, LOW);
digitalWrite(UP, LOW);
digitalWrite(DOWN, LOW);
digitalWrite(stateLED1, HIGH);
digitalWrite(stateLED2, LOW);
state = 0;
}
int leftValue;
int rightValue;
int upValue;
int downValue;
Cont:
||
void loop() {
upValue = digitalRead(X_pin);
downValue = 1023 - digitalRead(X_pin);
leftValue = digitalRead(Y_pin);
rightValue = 1023 - digitalRead(Y_pin);
analogWrite(UP, upValue);
analogWrite(DOWN, downValue);
analogWrite(LEFT, leftValue);
analogWrite(RIGHT, rightValue);
if (digitalRead(SW_pin) == LOW)
{
if (state == 0)
{
state = 1;
}
if (state == 1)
{
state = 0;
}
delay(500);
}
if (digitalRead(SW_pin) == HIGH)
{
if (state == 0)
{
digitalWrite(stateLED1, HIGH);
digitalWrite(stateLED2, LOW);
}
if (state == 1)
{
digitalWrite(stateLED1, LOW);
digitalWrite(stateLED2, HIGH);
}
}
}
||
switch the if (digitalRead(SW_pin) == HIGH) and low statements, does it do something if you press and hold?
you really need to keep track of the buttons state, rather than using delay
The intended/desired behavior would be to simply press the button to change behavioral states, press and hold should only count as a single press. Currently, the button does nothing.
even if HIGH and LOW comparisons are swapped?
I haven't saved or tried any changes yet.
long press may be needed due to the delay statements
intended behavior is possible
this is a good example of button handling https://www.arduino.cc/en/Tutorial/StateChangeDetection
Open-source electronic prototyping platform enabling users to create interactive electronic objects.
just change line 38 to INPUT_PULLUP and it should work with your joy btn
Swapping HIGH and LOW made no noticable difference.
the code runs through the loop so fast the state is changing all the time
except for 500 mS when nothing happens
Button reads high, 4.4v on multimeter. Drops to zero when pressed.
ok, so it is wired for input pullup, sounds like the button is ok
...my cat decided that he doesn't like the motors. He keeps swatting at my project.
lol
(Mental note to self: Consider using vibrating motors in future cat toy builds.)
Only certain color ranges.
was pondering RGB LEDs for cat toy...
They can see from somewhere in the IR band, up to about green. So blue, green and violet all looks the same to them.
just RG LEDs then 🙂
That's why when I design pet toys, I avoid using the color blue entirely. They get frustrated not being able to see them outdoors, or losing them in the grass.
no FastLED needed for pet toys <mental note>
I hate using the serial monitor. ...
Which is ironic, considering that I got into Arduino because I want to get back into developing HID devices.
what is the issue with serial monitor?
In my case, portability.
but it's great for debugging
i have print everywhere when i develop, then disable / remove for field use
I have a weird workspace setup. All of my computers are on a shelf under my gaming monitors, I use wireless keyboard, mouse, and controllers. My workbench is about 10 feet away, and the only USB cable I have to fit my R3 is less than a foot long.
oh, need a 5m USB B
I have one on my wish list, but waiting for payday, then delivery.
Along with my Leonardo board to start toying with HID builds more directly.
yes, hard with an UNO...
Eventually, I want to get back to building sim components. I used to use old junkyard parts to build driving and spaceflight simulation controls.
but had to stop when computers phased out serial ports, and adapter prices were prohibitive.
i built my buddy who flys RC planes a lawn chair with rudder, throttle, joystk, he sat there and flew by watching the video feed we sent back from the plane
If I ever won a lottery, I would build a full size spaceship simulation. The cockpit would have projection screens outside the glass, the interior would be fully immersive with separate rooms and compartments. Everything, from fuel mix, engine controls, to life support would all be micromanaged manually.
I'd make it like a sci-fi "Space Camp" where people could spend a few days living on-board.
everything is possible with enough money 🙂
I could even work on making a networked game using several of such simulations, so they could interact in some ways.
Every play Star Wars, Knights of the Old Republic?
Most of the game centers around the player, but between every location, they are on a ship called "Ebon Hawk" (if I remember it correctly). I would want to build a ship about that size. The interior space is just a little smaller than the Millennium Falcon.
In my dream build, it would be scalable. It would have options to automate systems if a person were not available to manage them.
and it all starts with getting 1 button to work
But typically, I think pilot, navigator, one or two gunners, an engineer for managing the engines and life support. Could probably come up with more, or add gunners or crew shifts.
ok, i gtg it's almost 3am, try that example and let me know what happens
Question on using USB power on the Arduino Nano - I want to power my project using a Nano and an LED strip using a USB power supply.
If I plug in the power supply to the USB port on the Arduino and power the LED strip from pin 4 (5V), is it going through the regulator on the Nano?
Ideally I don't want it to because the (60 RGB) LEDs will need a lot of power.
can fastLED read and put this array on my matrix display?
array([[[149, 145, 203],
[210, 234, 219],
[223, 50, 26],
[166, 34, 65],
[213, 78, 115]],
[[191, 54, 168],
[ 85, 235, 36],
[180, 140, 96],
[127, 21, 24],
[166, 210, 128]]], dtype=uint8)
Are you running Numpy on an Arduino somehow?
@candid solar The USB power input should be direct rather than through the regulator, though there are still some potential current limits on the USB connector itself, the board traces, and so forth, so if you have the option to connect up the LED power rail separately, it might be better. This would probably work, though.
Thanks, I'll try this. The other option is to cut off the USB connector, splice and solder the wires directly to the board
@cedar mountain no i made a python script with numpy lib that converts a img to an RGB array
That's why i was wondering if FastLED could read and output it on my matrix
I'm not quite understanding what you mean by "read", since the RGB array is in your script's Python code, and FastLED is on your Arduino. How are you imagining the Arduino gets access to it?
@cedar mountain easy... via socket :)
ESP32 = Socket Server
Python = Socket Client
🙂
That'd definitely work. You'll just need to convert the RGB array into some sort of byte format to send across, and then convert it back into whatever FastLED wants.
this works! so i would need that format if FastLED can't do the RGB format
but how i dunno
@cedar mountain It worked for about 5 min until the nano started smoking! Luckily I pulled out the power right away, the Nano still works. Time for plan B
I have kind of a general question
I have a TFT LCD screen
when I make some pixel art on my computer it looks a lot bigger on the LCD screen. On the computer if I view it in "actual size" its like the actual length/height are smaller than the LCD screen's.
then on the screen it fits well but the measurements (not pixel dimensions) seem bigger
is there like some DPI or resolution change here probably?
Yup, very likely.
thanks!
There are tons of different pixels per inch measurements for different displays. Depending on how you have your desktop set, the apparent pixels may be less than the available pixels. Even among the 240x___ Adafruit SPI IPS TFT displays (pretty hi-res for hobby displays), I expected them to be same PPI, but each is slightly different (135x240=242ppi, 1.3" 240x240=261ppi, 1.54" 240x240=220ppi, 320x240=200ppi)
Hello, anyone knows what this error means and how i fix it? Thank you!
@north stream "int Greenvalue" is a declaration of a variable. It looks like maybe your statement's backwards? Should it be:
int Greenvalue = digitalRead(ButtonForGreen);
ditto for Bluevalue...
@north stream "int Greenvalue" is a declaration of a variable. It looks like maybe your statement's backwards? Should it be:
int Greenvalue = digitalRead(ButtonForGreen);
@delicate coral i'll try that
@delicate coral it worked, thanks
I've got a dumb question motivated by laziness. I'm using an Arduino Uno as a tone generator, creating pulsed frequencies out of two digital pins, then combining the output of the two pins to a speaker to generate DTMF tones. In my prototypes I've been using diodes on the digital pins to protect them when I wire the two together. Now that I've soldered everything up I notice I've forgotten to put the diodes in--but the circuit still works and sounds great, no magic smoke was released or anything. Should I go back and redo the circuit to add these protection diodes or is it alright to call it a day?
For some additional context, this is the device https://youtu.be/y5_Er87pAJM
if i understand correctly you have 2 GPIO pins basically connected together?
yes
one pin may be high while the other is low, i think diodes are in order
to keep current flow down
before the magic blue appears 🙂
but cool project!
somewhere in my junk box is an old Radio Shack chip that generated DTMF
Now to figure out how I'm gonna get diodes in this thing haha
Thanks. I was originally going to use an mp3 board but forgot to, well, get the mp3 board
overkill for this
Making the uno output two frequencies simultaneously was difficult--the tone function only works for one output at a time 😦
almost all my processor time is spent flipping those pins lol
do the tones actually decode?
I'm not sure--I took design cues from other projects where they did decode, but they also had some additional circuitry to smooth out the square wave. I don't have any capacitors handy (this is a budget operation lol) so I skipped that step. I don't have any DTMF decoders around to check with
When I record the output and look at the spectrogram in audacity it's really noisy lol
call an 800 # with a "press 1 for..." voice tree...
Didn't seem to work with chili's phone attendant
some filtering may be needed for actual use, but great as an effect
Yeah, the DTMF test line I just called can't pick up on it either. Still fun to play with though haha
ask away...
O_o
@north stream use pastebin.com if you are trying to paste lots of code
I should also probably stop driving the speaker straight from the gpio haha. I need to shove a transistor in here and wire it properly to the power rail
@junior trench an op amp mixer with a few parts to filter will do wonders...
@north stream take a look at https://www.arduino.cc/en/Tutorial/StateChangeDetection
Open-source electronic prototyping platform enabling users to create interactive electronic objects.
you are on the right track but those 10 second delays will make it unresponsive
@reef ravine okay
also make each IF statement into its own block
right now the others could only possibly trigger IF RED = true
@reef ravine i fixed the delay and the blue isnt working and the RGB
@reef ravine this is how the rgb looks
@reef ravine and after i click green, it doesn't let me go back to red
for starters put each color into its own IF block:
if (Redvalue == true) { digitalWrite(RgbRed1, HIGH); digitalWrite(NormalColorRed2, HIGH); delay(1000); digitalWrite(RgbRed1, LOW); digitalWrite(NormalColorRed2, LOW); }
@reef ravine so what part should i delete from the code and put that instead of it?
all your if's run together, using {} as above makes them run one after the other
yah but where in the code?
if (Redvalue == true) { <====
digitalWrite(NormalColorRed2, LOW);
} <=====
okay
around each of the 3 if's
okay
but in the end you'll need to keep track of the "state" of each button
@reef ravine like this?
try that
@reef ravine that was the same thing i was using before you gave me it
gotta run to pickup dinner be back later
@reef ravine okay, i'll put the question again later
Hello. Is there any port of touchio from CircuitPython to Arduino? I have a Trinket M0 and I'd like to use capacitive touch on it using Arduino but haven't found an easy solution as touchio.
@north stream Still around?
you using a breadboard?
and a guy is helping
ok, i'll lurk
you using a breadboard?
@reef ravine yep
so..... I was planning on sending a LED color schema using URL encoding to a esp32(using all arduino libraries so in practice a arduino with a wifi module) because I thought that arduino didn't have a good JSON body handling library.... but now I am thinking that it might be better to pass the schema as a JSON body... I already have the code mostly done with URL encoding, but I don't really like it if I am being honest.... the code I wrote that uses URL encoding is here https://github.com/dylanpoll/EmailLightBar/blob/master/emailLEDbot/espRestfulLightBar/espRestfulLightBar.ino , I don't know how it will run yet as I have not done a trial run, will be doing that later, but if anyone can give me some input in if they think I should just swap off to a JSON body post and parse the data out?
this is the segment of the code that handles the URL encoding, it is followed by a switch case that sets the LED color arduino //this for loop just makes this setup a little bit easier. cycles through all the url encoded fields. for(int i = 0; i < NUM_LEDS; i++){ //if you change from num leds, account for 0 and make it <= String encodedField = "l"; encodedField += i; encodedField += "="; String diodeColor = "b"; //b will stand for black and fastled treats black as off if(i<10){ //if it is less than 10 the total chars used is 3 int fieldIndex = header.indexOf(encodedField); diodeColor = header.substring(fieldIndex+1,fieldIndex+1); //pull the value from the field for that LED } else{ //greater than 10 the total chars used is 4 int fieldIndex = header.indexOf(encodedField); diodeColor = header.substring(fieldIndex+1,fieldIndex+1); //this limits the substring value to only the char at the index value. }
@glad birch idk if what you are doing above or JSON is more efficient but have you seen https://arduinojson.org/ ?
no i have not D: but it looks like what I need thanks X/
its 30 leds, but I want to be able to scale so sending a json object would just be better overall I think X/
i found it pretty easy to use last time i needed JSON
@reef ravine Here's the spectrograph of a 350hz tone played by my method. I need a lowpass or something haha
was just playing around with https://www.falstad.com/circuit/circuitjs.html cool sim tool for op amps
I used to play on that site years ago, looks like he's upgraded from java applets!
the above is only the 350Hz tone?
That's the intention at least, yes
looks like all the harmonics are equal amplitude
roughly, slightly more intense at ~2.4k, 1.1k, and 3.2k
a simple RC would help big time
I was thinking that would be better than diodes anyway
Of all the assorted electronics I have strewn about, a capacitor just isn't one of them. I honestly am not sure why--I've got plenty of resistors, transistors, optocouplers, jumpers, LEDs, etc.
let's see 4 billion LEDs in parallel gotta be getting close to 1 nF 🙂
I've got two sheets of aluminum foil and a piece of paper
I've been known to shove aluminum foil inbetween the pages of a book for reasons
should give proper structure 😄
lol
For real though, I should've just bought/built the appropriate tone generator circuitry instead of doing it in software haha
wonder if those chips are avail...
The original DTMF generator chip is still present inside the pay phone, but I have it disconnected since I don't wanna deal with 48V
iirc it ran on a 3.58MHz crystal and you just gave it BCD
Bypassing that to get at the key matrix was super annoying, and the wire I'm using doesn't take to solder very well :X
that's not taking solder at all
Some of them did, which is what perplexes me. They're all cut from the same stock afaik
but that chip - can you scrap a bit of the blue stuff off to get the PN?
it's a TI of some sort...
At this point, not really. I'd have to dismantle the pay phone assembly again and I'm not keen to do that
oh, a build shot, thought it was in your hand
Yeah, I took that pic two days ago haha
Not gonna lie, this build was rough. I'm using what I have on hand at home, and what I have at home is the cheapest soldering iron available, flux core indium solder, and dupont cables
But it works ¯_(ツ)_/¯
hey if it works...
At the start of the build I didn't have a multimeter so I was checking consistency with a flashlight and some alligator clips (closing the circuit turned on the flashlight)
I stopped by harbor freight to pick up some spade connectors (needed to clip into the handset) and grabbed a multimeter, so that's sorted now
The flashlight is super sensitive, it turns on slightly even when I hold the clips in each hand
<surprised!>
but yeah, no way to tell what the resistance is, just relative resistance
"It's dimmer across this component, must be a higher resistance" haha
lol
tone() does indeed output a constant tone. I could probably use it for one of the two frequencies, rather than doing both of them the ghetto novel way
yeah i just looked it does keep going but you can only have 1
I do have two unos, but it seems like kind of a waste to use one of those just as a tone generator
I think at this point I'm committed, sunk cost and all that 😉
👍
hey if you have resistors.... https://create.arduino.cc/projecthub/dilshan-jayakody/generate-dtmf-tones-only-using-arduino-7d3713
where does the 500000 come from?
Microseconds per seconds / 2 (divide by two for pulse width from period)
gottcha
I do have enough resistors and pins to do that 🤔 . Though I wonder how necessary that capacitor is
you want ac coupled out to your amp
If you haven't picked up on it yet I'm pretty terrible at the actual electronic part of electronics
if you drive a fairly high impedance speaker you may get away without an amp, good enough for test anyway
i started the other way, hardware then software
That's the reference I used to guide my software design
I wonder if there's anywhere nearby I can pick up some capacitors
the linked code and lib didn't work?
huh, maybe I didn't get my design patterns from there. I do remember looking intently at that page though haha
i have all that stuff, maybe i'll play around with it
I am going to try that tone code now though
@reef ravine amazingly easier to work with this than it is with most of node and java's JSON libraries XD
i used it with a weather service, made the job much easier!
yeah, I already have it echoing my JSON posts so now all I have to do is attribute values to local variables XD
and I plan on cheeping out using a for loop and iterating over LED's in a array
so much better than hand coding every time you need more than a few bytes
Using the tone library from that page and no filter circuit, this is what my spectrograph looks like (770hz + 1477hz)
I forgot to put a resistor in before I soldered everything up and covered it in heat shrink tubing :X
heat shrink before test? <shakes head>
I did test it first, I'm just an electronics noob and it didn't occur to me that I should probably have a resistor in there until like 2 hours after I finished cleaning it up haha
did you try the test line with it ?
Yes, still no dice
those harmonics are really getting in the way it seems
that or my phone filters out dtmf frequencies from the mic
It doesn't sound noisy, but it also doesn't sound right with all those harmonics. But as this is just a prop it'll probably pass inspection by most people
if it makes different noises per button, yes 🙂
you really need a base current limiter
those pins are being dragged down to 1.4v
and i would use 5v for the speaker
When driving the speaker at 5v the leds on the board get visibly dimmer. At 3.3v they stay near full brightness. I don't really know what I'm doing outside of software
the diode drops .7v and the base emitter drops another .7v so the pins which want to be 5v are dropped to 1.4v, the transistor needs a few K between base and diodes
I could shove a pair in here without too much trouble, if my soldering iron will cooperate
pn2222a
ok, lemme scribble
yeah 1k will work there
then maybe you can drive the speaker harder with 5v
I've got plenty of resistors if you think another value would be better
that seems about right
ooh yeah, putting the 1k resistors in helps a lot. It sounds the same, but the arduino no longer looks like it's going to give out when driving the speaker at 5v
In the interest of not soldering anything at 1AM I've slipped the resistors in between the female connector on the 'duino and a female-female dupont, letting me connect everything with hopes and dreams
electrically, it now resembles the most recent screenshot. I really do wish I had a capacitor around though 😂
Thanks for all your help
you are welcome, i gtg but let me know how it works for you!
That sounds plenty good.
It's more likely electrical noise from the LEDs than a low voltage issue. You may be able to use some filter circuitry to isolate the LEDs from the other devices, to protect them from the noise or short duration voltage sags.
@north stream
Hmm are you sure the problem comes from the LEDs ?
Absolutely not sure, which is why I qualified my statement with "more likely", indicating that doing some research would be a good idea.
Oh ok ok, I tried doing some research but didn't find anything
@gritty hound do you have a voltage divider on the HC-0x modules Rx pin?
What is a voltage divider?
A resistance ?
If so, no
The Rx pin is directly on the pins of my Arduino
the HC-05 or 06 wants no more than 3.3v in
do you have an HC-05 or similar?
look on the back, see 3.3v?
On the power pin I see
"POWER: 3.6V-6V"
And on the RXD and TXD pins :
"LEVEL: 3.3V"
So yes
the RX pin does not "like" to see 5v from the arduino, so you need a "voltage divider"
the 3.3v FROM the HC-05 to the arduino is OK
This shows a Mega but it's the same for any 5v arduino https://howtomechatronics.com/tutorials/arduino/arduino-and-hc-05-bluetooth-module-tutorial/
Ok thanks so
Voltage divider = resistance
it uses resistors to divide a higher voltage to a lower one, 2/3 of 5v is ~3.3v
just thinking you may be barely working until you add noise to the circuit, try that and maybe your power problem will be solved
in any case you should not give 5v to the Rx pin
Ok I'll try when I finished eating thanks a lot
you are welcome
And yes I meant resistor, not resistance, resistance is in french
it is not a problem, i'm used to people who speak different languages
hi guys anyone could help me with arduino bootloader?
I think I bricked 2 mega328p this week
my isp programer cant even read signature now
is there anything what could be done except HVSP?
were you using "Arduino as ISP" or other?
also
but it read signature of 0x0000
but previously I used by usbasp clone
and I write fuses manually and then burn bootloader by avrdudess
maybe someone with more experience will see this and help, i burned a bunch of bare 328p's once and had no issues but used an UNO to burn them.
with external clock or internal?
This shows a Mega but it's the same for any 5v arduino https://howtomechatronics.com/tutorials/arduino/arduino-and-hc-05-bluetooth-module-tutorial/
@reef ravine
I don't understand why there are two resistances nor how to wire it. I hope I have a 1K and a 2K resistor
the ratio is important, 5v from arduino through a total of 3k (in this example)to ground. at the 2K the voltage is 2/3 of 5v. 10k and 20k would work as well.
@opal prawn i used an external 16MHz, hooked up as shown here http://arduino-er.blogspot.com/2015/01/use-arduino-uno-as-isp-to-burn.html (not a great tutorial, but external crystal)
the ratio is important, 5v from arduino through a total of 3k (in this example)to ground. at the 2K the voltage is 2/3 of 5v. 10k and 20k would work as well.
@reef ravine
I think the highest resistor I have is 220 Ohm :/
After searching the highest I have is a 470 Ohm
Use three of them?
Oh, ok
how do i remove a row of header pins from my arduino nano?
Are they soldered in?
yes
My usual approach for that is to either pry off the plastic bit that holds the header pins together (or snip it into pieces) and unsolder one pin at a time.
what tool do you usually use to pry off the plastic bit?
im having a tough time doing that
Usually a spudger or small screwdriver. If it really resists being removed, I just cut it into pieces with small cutters like flush cutters.
update: things are going good
i have half the pins removed
screwdriver did the trick
Hey all, the RGB matrix featherwing has an issue (ref https://learn.adafruit.com/rgb-matrix-featherwing/troubleshooting ) essentially it has an SMD 100k resistor that keeps my M4 from enabling accoring to the docs. The suggestion is swap it for a 10k, but I dotn have a 10k SMD resistor pack. Can I just jump bypass it? Is there some other answer to bypass this till I can order the SMD I need?
so this is from python side
def convertImage(self):
try:
img = Image.open(self.imagePath).convert("RGB")
img_array = img.tobytes().hex()
list = [f"0x{''.join(b)}" for b in batches(img_array, 6)]
self.string = ", ".join(map(str, list))
it sends a string to my ESP32 and i've been messing around with my 16x16 LED matrix and found a tutorial that uses a
const long pixelArt[] = {};
but how can i get that String coming from python side inside that array?
I seem to have a issue with neopixel and my esp32
it has really bad color matching, sometimes the LEDs flicker different colors while updating the strip
most times color values show differently at different positions despite being correctly attrributed
ahhhhh I think I figured out my issue, its library issues with the esp32 and neopixel, swapped off to neopixelbus and now its all good ;D
Hey guys, how goes?
I'm slowly working on getting back into soldering/microsoldering and took on the trinket volume knob tutorial: https://learn.adafruit.com/trinket-usb-volume-knob/add-a-mute-button
I have arduino IDE loaded, and pasted the code with the mute button function, but when I go to verify I'm getting: TrinketHidCombo.h: No such file or directory.
Did you install the library in the previous tutorial step?
I did yeah. I guess I was rushing this, and didn't install/select the proper .json information. So, now I'm going back through and reading SLOWLY so I don't miss anything.
I'm following the config now to set up IDE properly also, making sure this time I don't miss anything.
Okay. Drivers installed, json configured and trinket 5v USB set up. Exited and reopened. When trying to verify it now, I'm getting a stray \302 in program
Anyone?
@fluid dragon That seems to be a non-breaking space character. Not sure how it got into your code... maybe retype any whitespace in that line.
Honestly, didn't type anything. Only copied/pasted from Adafruit, and downloaded the TrinketHidCombo.h file.
I'll try a recopy/paste on the initial code w/mute button.
The copy-paste probably did some HTML whitespace mangling.
Can you download the code instead?
Just rename to something.ino.
I have a feeling I have the wrong board selected maybe?
lemme swap out and go direct to PC instead of USB hub.
nope, didn't do any good.
Which Trinket do you have? There's a Trinket, Pro Trinket, Trinket M0...
Gotcha. The error message says it was expecting a Pro Trinket, so you might need to install a different library? I'm not completely sure what hardware the code supports.
totally not sure why it's asking for pro trinket hardware. Assuming ATtiny85@8MHZ is correct?
terminating ' character mssing?
<!-- '"` --><!-- </textarea></xmp> --></option></form><form class="js-jump-to-line-form Box-body d-flex" action="" accept-charset="UTF-8" method="get">
where?
Huh? That doesn't look like code at all. It's a web page.
That looks like you saved a GitHub web page instead of the raw code file itself.
welp,m fix that. Possible progress?
Disclaimer, I'm not a coder/programmer by any means. Hardware is moreso my area.
What does TrinketHidCombo.h look like now?
Gotcha, back to that Pro Trinket versus Trinket error. I'm not sure whether this is supposed to work on the lower-speed board or not.
can arduino's use .env files?
i have a 120x120 BMP that i want to show full-screen on a 240x240 display (tft GIZMO) . I'm using arduino. Is there a way I can do this, without resizing the image to 240x240 (and making it 4x as large) as i have lots of images i need to display and limited storage
@river osprey Can you resize the data while you're copying it to the TFT's display memory?
Could somebody tell me why this doesn't work? when I type in hello , it gives me hello correctly but it doesn't give me goodbye like stated
You can't do x == "hello"..
@raw forum "x" is a pointer to the location where "hello" is stored. in C to compare strings strings you use the function strncmp() https://forum.arduino.cc/index.php?topic=236444.0
I think with String it is if (x.compareTo("hello") == 0)
ah @lone ferry has a better way https://www.arduino.cc/reference/en/language/variables/data-types/string/functions/compareto
I used Matthijs solution but still didn't work or did I do something wrong? And jerryn some other people suggested me to use char arrays but do I have to? can't I use strings?
Try Serial.println("goodbye") instead of print
Oh I think the problem is that your string x also includes \r and/or \n characters. You'll need to strip those off before doing the comparison.
How to I strip those off?
x.trim(\r && \n);
like that?
It is the first time I'm using strings so I'm a bit of a noob sorry haha
No, literally just x.trim();
Yay! Well done @lone ferry !
@lone ferry thank you!!
actually, Serial.readStringUntil('\n')
Does that skip over the \n next time you try to read from Serial? @candid topaz
@candid topaz @lone ferry that works as well
Returns
The entire String read from the serial buffer, up to the terminator character
"The terminator character is discarded from the serial buffer." So yes, I guess. 🙂
This is the python side of my code where i take an image (16x16) and convert it to R G B string and then sends this via SOCKET to my ESP32
def convertImage(self):
try:
img = Image.open(self.imagePath).convert("RGB")
img_array = img.tobytes().hex()
list = [f"0x{''.join(b)}" for b in batches(img_array, 6)]
self.string = ", ".join(map(str, list))
print(self.string)
except Exception as e:
print(e)
then in in my arduino sketch (using ESP32) i have
const long pixelArt[] = { }
it should look like this
const long pixelArt[] = { 0x000000, 0x000000, 0x000000, 0x000000 }
then i display it on my 16x16 LED Matrix like so
void PrintImage() {
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = pixelArt[i];
}
}
the incoming string from socket is this
StaticJsonDocument<256> doc;
deserializeJson(doc, payload);
if(doc["pixArt"]){
doc["pixArt"]; // This is the string from the python inform of a json
}
my question is how do i get that string inside that const long array? :/
My suggestion would be to parse the incoming string and populate the elements of the array.
I'd suggest not sending it as a string but as the actual binary data. Then you can just memcpy the data into the array.
how what huh? 🙂
Best place to learn Arduino C? I find a lot of things but they are all basics and I already know the basics
I really just need to know the syntax
@elder hare If you want to use JSON to send this stuff, you can base64 encode the pixel data from the NumPy array and send it to your ESP32. Then you base64 decode this data and memcpy it into your pixelArt buffer. (However, you should send the data as 4 bytes per pixel instead of the 3 bytes you're using now.)
@glossy sierra for syntax -- this may be helpful https://www.arduino.cc/reference/en/
@lone ferry why 4bytes tho?
@elder hare Because a long is 4 bytes.
I mean, you can send them as 3 bytes per pixel from the Python script but then you have to convert them to 4 bytes per pixel anyway.
oh? im a beginner at best at this 🙂 just started messing with my 16x16 LED matrix
The reason I recommended sending the data as binary is that you don't need to parse it. If you're sending it as 0x12345678, 0xff00ff00, etc then you need to parse this text data back into numbers.
btw im not using numpy
Ah you're right, you're doing img.tobytes(), not img.toarray(). But that doesn't really matter here. 😉
true just wanted to mention it 😛 hehe
on the python side i just found out i dont need map and str in the join... :P
befor :
self.string = ", ".join(map(str, list))
after :
self.string = ", ".join(list)
still outputs the correct format
0x66cccc, 0x66cccc, 0x66cccc, 0x66cccc, 0x66cccc, 0x66cccc, 0x000000, 0x000000, 0x000000, 0x000000, 0x66cccc
Because you say "correct format", I'm afraid that you think you can use this in your ESP32 program like that. You can't use Python to generate C source code like this, because source code only works at compile-time, not when the program is already running...
i think its "correct format" if you want to copy/paste that code to arduino program 🙂 but not for live streaming images from pc to arduino
i hate programing in 2 languages -.- sucks
@odd fjord so how close to actual C++ or C is Arduino C?
C++
i think its "correct format" if you want to copy/paste that code to arduino program
I guess that depends on whether the TFT uses alpha channel / whether the bytes are ARGB or RGBA.0x66ccccmight be interpreted as00red,66green,ccblue,ccalpha 😉
@glossy sierra For a little extra information regarding the Arduino 'programming language' if you are curious: Arduino is not a programming language, it is a library that help simplify some of the lower level C instructions. It seems like it's own programming language when using the Arduino IDE as it automatically #include <Arduino.h> just like any other library without actually displaying it, and generates function prototypes among other things like saving files as .ino instead of .cpp (https://www.arduino.cc/en/main/FAQ). When switching to another IDE like VSCode + PlatformIO extension, you program Arduino boards using C++ files, and just include the Arduino.h file.
Open-source electronic prototyping platform enabling users to create interactive electronic objects.
hey guys, I'm a proper noob, I had a stroke and im trying to measure EMG signals. Long story short I got this https://wiki.seeedstudio.com/Grove-EMG_Detector/, and I cant work out how to connecr it to my arduino uno. any help?
i dont know what gnda, vcc, nc, vout means in relation to my arduino
any pointers would be greatly appreciated
GNDA will be your Arduino ground.
VCC will be your Arduino +5V
NC is "no connection", you don't need to so anything with that pin
VOUT is the analog signal from the sensor, connect it to one of the analog inputs of your Arduino
кто может помочь с кодом на ардуино?
anyone know how to change the ssd1306 splash in arduino? https://forums.adafruit.com/viewtopic.php?f=60&t=166765
@sour tide I just responded on the thread, hopefully that helps them
thanks!
Does anybody know where I can buy labeled Leonardo headers? I found a board that I want to get which promotes the idea of "Young Women in S.T.E.M. Programs", but they do not have labelled headers like most of my other boards have.
Thanks again for replying @frank linden. Looks good!
Looks like there's some weird stuff in your arduino/libraries directory, which is confusing it. I'm not sure what TheBlink_june11d is, but perhaps it doesn't belong there?
OH
anyone knows how i can connect one wire to 4 areas? its the wire that comes from the ultrasonic sensor ground.
@north stream are you using a breadboard?
yes
ok, are you asking how do all the ground wires get connected?
I'm sorry that its not clear, let me clear it
@reef ravine what I'm asking is how the wire that's from the ultrasonic sensor's ground, its connecting there and 3 other areas in the LCD,
it looks like an omission from the drawing, all the ground wires should be in common, the same place as the buzzer ground
what do you mean?
generally black wires are used to indicate the wire is ground. all the black wires should be connected together, and to the arduinos ground
but how do i connect 1 wire to all the areas?
Question -- I had a ESP32 inland board given to me. Looks like it is from Microcenter.. Does not say what board to select in the Arduino IDE.... have done a basic search for tips online (can't find anything) Unlike ESP8266 in the Arduino IDE I do NOT see a "generic"verision,, Name of the board is just "ESP 32 Core Board" (Using Ardiono 1.8.7) *Would love to connect this board to Adafruit IO
on the breadboard do you see the columns on either edge, marked in red and blue typically?
@quartz furnace does this help? https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/
@north stream so just wires from part to part?
you are soldering them?
nope
@quartz furnace does this help? https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/ I have done that --just don't see a good option in the long list of boards
@reef ravine
im connecting them from the area that its supposed to be connected with no soldering
can you send a picture? i am not sure i understand what you are doing
okay
well im doing like the image like i told you before
no solder
let me send you the link of the vid
https://howtomechatronics.com/projects/arduino-security-alarm-system-project/ ► Find more details, circuit schematics and source codes on my official website.
In this project we will learn how to make an Arduino Security and Alarm System. You can watch the following video or ...
@reef ravine i cant send a pic of what im doing cause i wanted to connect that the first
sorry
@quartz furnace the inland site says "ESP-WROOM-32", no such option?
@north stream if you aren't soldering and aren't using a breadboard then yes please, i don't follow
@reef ravine Correct, I don;t see that listed as an option
@reef ravine it'll take me about 5 mins. sorry
@north stream If I understand correctly, you are trying to connect the GND black wire to the Arduino in multiple spots. The Arduino Mega has multiple GND ports, as seen in yellow in the picture attached. Simply wire the ground wires to any of these pins.
@quartz furnace i know what you mean, i haven't loaded esp32 yet (just 8266), try various options with a blink sketch and see if it compiles
@north stream If I understand correctly, you are trying to connect the GND black wire to the Arduino in multiple spots. The Arduino Mega has multiple GND ports, as seen in yellow in the picture attached. Simply wire the ground wires to any of these pins.
@frank linden yep
Is that enough ground pins for what you are trying to accomplish/am I understanding you correctly?
Is that enough ground pins for what you are trying to accomplish/am I understanding you correctly?
@frank linden what do you mean?
Since I kind of came in in the middle of the discussion, I want to make sure you are just trying to connect multiple ground wires to an Arduino
yep
i think the issue is the diagram from that tutorial is missing a ground wire...
i think the issue is the diagram from that tutorial is missing a ground wire...
@reef ravine how do i fix that?
just connect all the black wires to one of the grounds that @frank linden showed
how can i connect all of them?
there are 5 yellow dots in the diagram above, use any of them
These are the ones for the Uno, there are only 3
a breadboard is handy for this, the uno has three sockets marked ground
plus ICSP but not going there...
i think you will need a breadboard
Do you have any female header? You may be able to work off the ISP ports
Do you have any female header? You may be able to work off the ISP ports
@frank linden what do you mean?
to start with basics, how are the wires connected to the ultrasonic sensor?
should i show you how mine is connected?
ok, or are you using push on wires?
ok, or are you using push on wires?
@reef ravine i dont know whats push on wires so ill send you how mines looks
one sec
ok
how much does an arduino cost
@reef ravine here
@pine bramble it depends on where you buy, which model, genuine or clone, $5 to $30 US
@north stream The part of the cable you plugged into the ultrasonic sensor are female connectors, the ones you would plug into the Arduino are male
woah that cheap
@north stream The part of the cable you plugged into the ultrasonic sensor are female connectors, the ones you would plug into the Arduino are male
@frank linden okay
@north stream what is at the other end of the wires, do they have pins?
i didnt connect it
is it bare wire? a pin?
its a pin
ok, do you have wires with both pins and female connectors?
ok so those will plug in with no problem, do you have more wires or only those?
lot more
look and see if you have wires that are male on one end and female on the other end
ok, and you need one more ground connection correct?
okay
this?
yes, there is another ground there
ya
If this helps, wire it to anything circled in orange
If this helps, wire it to anything circled in orange
@frank linden what do you mean?
Any of those pins/the ones AnonEngineering is talking about, are all wired together
They are all ground
Yes, those included
okay
But only the circled one, that say GND
like this one right?
Yes
yes
Connect that where the black wire went in the diagram
i dont get what you mean
sorry
can i call with someone so i can understand what you mean better please?
do you have a wire that is female on one end that will connect to where you need it?
you mean a side that has the pin and another that doesn't?
yes
the female end will push onto the ground pin we were showing
yes
then you have another ground connection
four, including that pin
right now, what is missing a ground in your circuit?
which part is missing the ground?
Looking back at the diagram, it appears you need 6 GND connections
ground = GND
Unfortunately I cannot call
its how that one wire is connected to 4 areas @reef ravine
Unfortunately I cannot call
@frank linden its okay
on the LCD?
its how that one wire is connected to 4 areas
@north stream
are there wires there or pins?
yep
all 3 black lines on the LCD are pins?
what do you mean
can you post a pic of the LCD showing its connections?
mines?
yes