#help-with-arduino

1 messages · Page 45 of 1

inland crag
#

oh ok

#

hmm I wonder if the library isn't compatible

#

is there more to the error message?

pine bramble
#

no

inland crag
#

you can probably scroll the black window at the bottom

pine bramble
#

exit status 1

#

Error compiling for board Arduino/Genuino Uno.

#

that's all i see

#

hmm ok lemme see

#

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno"

In file included from C:\Users\Tarun\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.cpp:15:0:

C:\Users\Tarun\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.h:36:29: fatal error: Adafruit_Sensor.h: No such file or directory

compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

#

this is the entire error message

north kelp
#

@pine bramble Try turning on verbose output.

inland crag
#

ok there we go, you probably need the unified adafruit sensor library installed

pine bramble
#

hmmm

#

what is an verbose output?

inland crag
#

install it the same way you installed the dht lib

#

verbose output means more detailed error messages

pine bramble
#

can i send u the entire code in DM?

#

i am using multiple sensors

inland crag
#

I think you just need to install the adafruit sensor library

pine bramble
#

i did

north kelp
#

Yep, you likely need to install Adafruit Unified Sensor library. Try that.

pine bramble
#

hmm ok lemme see

north kelp
#

Sketch > Include Library > Manage Libraries…
then search for Adafruit Unified Sensor

#

It may be at the bottom of the scrolling list.

pine bramble
#

ok

#

got it

north kelp
#

That's in the guide section I pointed you at earlier. 🙂

#

But it can be easy to miss a step.

pine bramble
#

there was a diff one

#

DHT.h that was the one i found in the link u sent

north kelp
pine bramble
#

i did it now it says : 'DHT' does not name a type

north kelp
#

Are you trying the DHTtester example?

pine bramble
#

no

north kelp
#

I would suggest working through that section of the product guide completely, which includes the DHTtester code.

#

That will ensure you have everything set up.

signal plaza
#

Is it possible to use an existing C library within the Arduino IDE?

  1. The library comprises '.h' and a '.cpp' files.
  2. The library does not already exist under existing 'manage libraries' option in the IDE ( I download it from github).
  3. When using the 'include zip' option (https://www.arduino.cc/en/guide/Libraries#toc4) then I get an error -
    https://downloads.arduino.cc/libraries/library_index.json.sig file signature verification failed. File ignored.
    All thoughts welcomed.

For info - library location is: https://github.com/pavelmc/Si5351mcu
Thanks

north stream
#

You can make it into an Arduino library, but it's generally easier to just put the .c and .h files in the same directory as your .ino file.

signal plaza
#

Thanks for that. I will give it a spin!

#

Update - I have the library files copied into the same directory as the '.ino'.
However I am still getting the file signature verification error.
I do not know if this is fatal or just for info.
Assuming the former, is there a fix?
Thanks

north stream
#

What are you doing when you get the signature error?

signal plaza
#

Merely editing the '.ino'.
The processor board is not connected at this stage.

north stream
#

I had no idea the code editor had a signature check. I was guessing you were getting that error from the compiler or library manager or something.

signal plaza
#

OK. I saved the '.ino' and restarted the IDE.
No error at this stage, even when I edit again, so no idea why that popped up.
I guess the proof of the pudding will be when I attach the board and try to compile.
I did notice that now I have three tabs showing as below.
I remain unclear how my code accesses the '.cpp' - do I need another 'include' for that?

north stream
#

The linker will include the .cpp file with the .ino file, you will need to #include the .h file in your .ino

signal plaza
#

Done deal.
Thank you again.

pine bramble
#

@signal plaza Your .ino may be empty (entirely). If you do so, each .cpp file must have a header:

#include <Arduino.h>
#

The one directory name automatically recognized, is

./src
#

It will find all .cpp files anywhere under ./src within reason (may not look in ./src/.directory for example).

#

Only one .ino per project, though.

north stream
#

Ah, that's good to know. I'd had issues with typedefs in the past, and just dispensed with them instead of investigating.

pine bramble
#

I never did prove that ./src was the only allowed directory name, one level down from the project level.

#

I tried it experimentally on a hunch. It worked. Nothing else did.

#

I kind of held the Arduino IDE and overall system in disdain, until I worked with Atmel Start (sort-of 'bare metal' or maybe just 'manufacturer's libraries/methods, only').

north stream
#

For the curious, here's the main that the Arduino code uses: ```c
int main(void)
{
init();

initVariant();

#if defined(USBCON)
USBDevice.attach();
#endif

setup();

for (;;) {
loop();
if (serialEventRun) serialEventRun();
}

return 0;
}

pine bramble
#

Nice syntax on that for loop ;)

north kelp
#

@pine bramble I think I’m going to start pronouncing that pattern for 😉😉

pine bramble
#

for (; ;)

north stream
#

Default initializer (no-op), default test (true), default incrementer (no-op)

pine bramble
#

I think O was trying to say they look like smilies emoticons.

#

When people do all those =D things I just ignore them as untranslated emoticon.

north stream
#

O_o

pine bramble
#

See I have no idea what that'd mean. 'bubble memory' comes to mind. ;)

#

I borrowed this one from a MOO I think:
.oO( .. thought balloon)

rough torrent
#

Is it possible to have multiple callbacks in the same program? Like if I had one callback running some audio playback and another incrementing variables and stuff like that?

north kelp
#

@rough torrent Like multiple interrupts?

#

What are you making?

rough torrent
#

I'm on a PyGamer using Arcada

#

I'm making a wav player

#

I use one for playing the wav files

#
void wavOutCallback() {
  wavStatus status = arcada.WavPlayNextSample();
  if (status == WAV_EOF) {
    arcada.timerStop();
    arcada.enableSpeaker(false);
    playing = false;
  } else {
    playing = true;
  }
}
#

And the other times the wav file being played

#
void wavTimeCallback() {
  if (playing && !paused) {
    wav_time = millis() - wav_start_time;
  }
}
#

I set up both with arcada.timerCallback(speed, pointerToFunction);

surreal pawn
#

I would expect the last one to overwrite the first

north kelp
#

@rough torrent I'd try it, and see if it works. I think it should, as long as variables like playing, paused, wav_time, etc. are declared with the volatile keyword, and you're careful to do as little work as possible inside the ISRs (callback functions).

#

Basically any global variable you're changing inside an ISR callback needs to be declared volatile.
Also, you need to register each callback separately.

surreal pawn
#

It does replace the timer callback

#

Those are small enough to gave in the same callback function though on pygamer

wind drift
#

I need some help with an arduino code.

I am using a barcode scanner from which I want to save the code into a variable and print it

#

Right now the numbers are chopped somehow

#
  while(barCodeSerial.available()){
    delay(1);
    code += (char)barCodeSerial.read();
        }

  Serial.println(code);
  code = "";
}```
#

This is my loop

north kelp
#

@wind drift It may be that while the reader is sending you as much as it has at a given time, there are some tiny pauses, and your code thinks that's the end of that segment.

wind drift
north kelp
#

Does reader send a special character at the end of a barcode, like maybe ASCII 13?

wind drift
#

I don't see any - or is it an invisible character?

north kelp
#

Can you point to an link to the barcode reader you're using?

wind drift
#

oof not sure - I only got a chinese doc with it

#

mostly chinese- a little bit of english in there

north kelp
#

In absence of a special character, I'd go with a timeout strategy. Can you point at the Chinese doc?

north kelp
#

Is there an Arduino library it uses?

wind drift
#

Nope

#

I just plugged it into a digital pin and read the code through softwareserial

north kelp
#

Sweet

wind drift
#

Okay I found a sort-of-temporary fix - I increased my delay from 1 to 5 ...
But I can imagine it will give me some problems lateron with false readings or something.
I am open to better ideas 😄

north kelp
#

If there's no special character, than I'd do a timeout approach, and a state machine.

  • create a global variable uint32_t lastReadTime, and bool inString = false, and set the first to millis() in setup()
  • each time a character comes in, reset lastReadTime to millis(), and set inString = true
  • in the loop if there's no character available to read, set uint32_t curReadTime = millis();
    ** if inString == true, and if curReadTime - lastReadTime > 250, we've waited long enough. Output the string, and reset inString to false. And erase our buffer.
#

Basically, keep reading characters and appending them, but if 250ms passes and nothings coming in, we dump what we have. Could be 100ms, or even smaller.

wind drift
#

something like this?

#

Thanks!

fallow wind
#

does anyone know how can I generate a .hex file to upload using software such as Xloader?

north kelp
#

Awesome, @wind drift ! You interpreted my rough rambling into real working code!

#

Try a really small threshold, like 50 ms! That may be enough, and would be super fast. On the other hand, if it's too small, you'll see the issue you had earlier. So it's a tradeoff between lag time (currently 1/4 second) and reliability.

pine bramble
#

@fallow wind The .hex and .bin files are in the same directory.

fallow wind
#

oh? I usually just sketch and upload, thanks @pine bramble !

pine bramble
#

Heh, you're welcome. I haven't figured out how to use the .hex files. There's two of them for each build (one has a bootloader, judging by the name it gets).

north kelp
#

I did not know about either of these!

pine bramble
#

There's also the .elf file which I think is used with objdump and the source code tree.

fallow wind
#

thank u both, I'm getting the hex file and I'll let u know tomorrow when I upload it

north kelp
#

I've also compiled and installed onto Adafruit Express boards, then grabbed the .uf2 off the virtual drive the Express devices mount in the file system. I (or customer/client) can drag this to a mounted device, as long as it's identical.

#

No Xloader needed in that case!

fallow wind
#

I'm just looking to upload a custom grbl to a nano which has another custom grbl without bootloader (I think that's the thing requited to upload new sketches into the arduino)

#

thx for the help!

pine bramble
untold ingot
#

Ahoy there! I’m trying to get this TFT display to work. Does anyone know what can cause this bug?

untold ingot
#

Nevermind, found the answer here:

wind drift
#

Does someone have an easy example for switching a neopixel led color to a differnt color by pressing a button?

#

neopixel on the nrf52480 feather express

wind drift
#

okay now I am even more confused than before. Somehow the BLE example code is not working anymore. It's no longer showing in the list and there is no blue LED. I tested it on 2 nrf52480 feather express boards

#

Ok nevermind got the ble working again. Forgot to open the terminal

#

But still not sure how I can control the neopixel on the board ...

#

Or is that not possible?

north kelp
wind drift
#

Ohh I see let me try that

wind drift
#

@north kelp I worked around a bit more with my barcode scanner. I noticed that I can apparently get a special character

#

See the questionmarks

#

but how can I 'detect' it?

wind drift
#

I tried different baud rates but they all show the questionmark

#

I can get a -1 if I don't add the (char)

north stream
#

Possibly an "end of code" symbol, or your read routine returning a -1 because there's no more data available?

north kelp
#

@wind drift I'd try casting the character to a number; this (untested) code should give you the raw ASCII character number: ```cpp
Serial.println((uint16_t)barCodeSerial.read());

#

Oh wait; maybe what you're doing already does that?

#

Anyway, I'm guessing that the end-of-barcode byte may be -1 (signed) or 255 (cast to unsigned). Testing for this could be easier and faster than doing a timeout. Doing both (“suspenders & belt”) would ensure the system could recover if there's some odd transmission glitch.

wind drift
wind drift
#

Okay got another question.
I want to have a timer counting down from 5 to 0 and then print something. But I am abit confused about the millis function. How would I do it there? I only got it to work with delay

#

The timer should start after I press a button

north stream
#
#define SECONDS(x) (1000 * x)
#define UPDATERATE  SECONDS(1) // update this often
#define COUNTDOWN SECONDS(5)    // count down from this much
unsigned long  curtime;
unsigned long  next;
unsigned long  timetogo = 0;

void loop() {
    curtime = millis();

  if (digitalRead(switchpin) == 1) {
    // set countdown time
    timetogo = curtime + COUNTDOWN;
    next = curtime + UPDATERATE;
  }

  if ((timetogo != 0) and (curtime > next)) {
    // time for an update
    if ((timetogo - curtime) > 0) {
      // still going, print current value
      Serial.print((timetogo - curtime) / 1000);
      next = curtime + UPDATERATE;
    } else {
      // done
      Serial.print("Done!");
      timetogo = 0;
  }
}
#

A little sloppy, but that's one way you could do it.

#

I skipped over some stuff like configuring the switch pin and setting it as an input, etc. but I think I hit the basics of starting a timer, emitting its value at regular intervals, and stopping when it's done. Another approach would be to just use next with millis() and simply count seconds with timetogo, which could avoid roundoff error and and the need to zero it when the timer runs out, but if the CPU gets distracted for significant time, could lead to lost seconds.

wind drift
#

Thanks

#

But somehow I can't get it to work

#

Or do I need to edit something first?

north stream
#

Can't get it to work how? Does it compile?

wind drift
#

Yes it does

#

but the terminal does not show anything

wind drift
#

Okay I tried a normal counter with millis (1000)

#

I noticed the timing is a bit off?

#
{
  boolean newState = digitalRead(BUTTON_PIN);

  if((newState == LOW) && (oldState == HIGH)) {
      delay(20);

    if(newState == LOW) {
      counter = 5;
      startMillis = millis();

      while (counter >=0 ){
        currentMillis = millis();

        if (currentMillis-startMillis == 1000){
          counter = counter-1;
          Serial.println(counter);
          startMillis = currentMillis;
        }
      }
    }
  }
 oldState = newState;
 //  Serial.println("not counting");
}```
#

I just tried this one

#

it is sort of counting down

#

but it prints it all at once

#

so I press the button - then nothing happens - after 5 seconds it prints the 5 numbers all at once

#

And why is it printing the -1

acoustic nebula
#

you're decrementing the counter before printing it in a loop which allows it to be >= 0. When it's 0, it enters the loop, you decrement it, then print it --> -1

wind drift
#

Ah right

#

Any ideas about the print delay?

#

I am guessing the while loop is the problem

north stream
#

Could be that it's not exiting loop(). The code has changed a good bit

wind drift
#

Well basically I am checking if the button is pressed then set counter to 5.
Check current time and set as startmillis.
Then as long as the counter is >=1 check the current time and set as currentMillis
if currentMills-StartMillis == 1 second set the counter -1 and print it
And set the new startmillis to currentMillis

#

From my thinking it should print them 1 by 1 every second

north stream
#
void loop()
{
  unsigned long curtime = millis();
  boolean newState = digitalRead(BUTTON_PIN);

  if ((newState != oldState) && newState == LOW) {
      counter = 5;
      next    = curtime + 1000;
  }

  if ((next != 0) && (curtime > next)) {
    --counter;

    Serial.println(counter);

    if (counter == 0) {
      next = 0;
    } else {
      next = curtime + 1000;
    }
  }

  oldState = newState;
}
wind drift
#

I assume int next?

#

Hm it does not seem to work

#

ah kinda got it

#

ah got it now - forgot the counter=5

#

perfect - thanks!

north stream
#

Looks good

wind drift
#

@north stream I have one more related question. I am trying to measure an object on a scale. Usually they 'save' the measured value after 3 seconds, when the weight is stable

#

How would I do that?

#

I notice that my scale is putting out different values everytime (.x grams)

#

So I guess I have to make a range x > value < y

#

But not sure how to combine it with the timer

north stream
#

I might do something like set "last out of range" time to millis() when the "in range" check fails, and when it succeeds, compare the "last out of range" time with the current time: if the difference is more than the settling time, accept the value.

wind drift
#

Soo I would put it in a while loop?

left cairn
#

I think this is the best place for my question. Working on an Arduino Uno shield, trying to solder some wire onto the end of an already soldered pin. I have solid core wire - would this be easier with stranded? I’m having a really hard time getting things together. Sorry for the potato quality picture, but you can see the pins I need to solder these wires to.

pine bramble
#

Stranded wire is mostly for when you need it to flex all the time, like a headphone's wires (or a 120 volt power tool, for example).
Solid is better in every other way, and is usually easier to work with for soldering.

#

Best bet: experiment; your soldering technique will prefer the one or the other.

#

(You can sometimes cheat and use only half the strands, for example, to fit a smaller area, so stranded in that case works better).

left cairn
#

Okay, maybe I’ll keep tinkering with the solid core before I spend money on stranded. Thanks!

#

Sucks that I couldn’t use more of the breadboard style connections lol

pine bramble
#

You can use header pins and save a lot of trouble.

#

The 'Assembly' instructions for many Adafruit products shows an easy way to secure them, using a spare breadboard as a holding jig, during soldering.

#

If your protoboard has 'busses' (several holes connected together by copper foil) you don't have to worry about multiple connections to a single header pin.

left cairn
#

They’re actually the other side of a set of header pins! This shield is going to be an easy-use ISP programmer shield, so I have (female) header pins to house the board to program (a digispark) and am running wires from the GPIO pins to the bottom-end of the headers.

Now that you’re mentioning it, however, extra long headers would have made this easier

pine bramble
#

Yeah sometimes you can cheat with extra long headers and jumpers underneath.

#

Other times soldering is the only game in town.

tacit summit
#

Hello all I'm new to this please bare with me not a tech savvy person, I just purchased tv be gone, I'm working on a project to code it. Have you ever heard of IRJ4?

potent ferry
#

Possible that no one can help me ? :(

i am having hard time in figuring out what arduino code would allow me to use 2 accelerometers to control the rotation of one servomotor.

The idea is to wear the 2 accelerometers on the feet, 1 accelerometer per foot and based on how fast or slow i step in place, the rotation of the servo motor changes and stays at 2 specific angles .

Let's say 90 degree is the angle of the servo associated to no movement of the accelerometers.

110 degree is the angle of the servo associated to the stepping/walking in place at a costant low frequency of movement of the feet/accelerometers

130 degree is the angle of the servo associated to the stepping/walking in place at a costant higher frequency of movement of the feet/accelerometers

Any help please ?

north stream
#

I outlined a solution before, and you said you didn't understand it, I'm not sure what to do.

wind drift
#

I guess you could check the accelerometers values and see how they change over a certain period of time

#

Similar to a stepcounter

potent ferry
#

@north stream , i have no idea how to put your idea in arduing coding lines

"I'd probably have something like "note the timestamp when the acceleration goes through zero in a positive direction", "note the timestamp when the acceleration goes through zero in a negative direction", subtract the timestamps to get the elapsed time, then if it's small (more frequent motions) set the servo to a bigger angle, if it's large (less frequent motions), set the servo to a larger angle. Probably need to fold in logic to look for reasonable sized peaks in-between, to avoid spurious crossings, and to cross-check the two accelerometers for alternate motion."

north stream
#

Something like: ```c
#define FASTPERIOD 200
static bool foot1pos; // foot 1 currently positive acceleration
static bool foot2pos; // foot 2 currently positive acceleration
static unsigned long last1; // last time foot 1 went to positive acceleration
static unsigned long last2; // last time foot 2 went to positive acceleration

void loop()
{
unsigned long curtime = millis(); // current time
unsigned long period; // time between steps

if (readaccel(foot1) > 0) {
if (!foot1pos) {
// foot 1 going positive
period = curtime - last1;
if (period > FASTPERIOD) {
// long period means slow gait, set slow angle
setservo(slowangle);
} else {
// short period means fast gait, set fast angle
setservo(fastangle);
}
// remember parameters
last1 = curtime;
foot1pos = true;
}
} else {
if (foot1pos) {
// foot 1 going negative
foot1pos = false;
}
}
}```

mild elk
#

I have this very weird problem with Arduino pro mini: it cannot be programmed. Not with serial, not with ICSP. I know it works beause it runs a default blink sketch, but other than that I can't do anything with it

potent ferry
#

I am not sure how to paste the code in here like you did

#

based on my code above, how can your code be adapted

#

?

#

I undertand the code I shared with you, but I can't figure out how to define the values for the code you shared.

#

I am so ignorant on this

north stream
#

I'm in the middle of a little home disaster, and don't have the bandwidth to do a code merge right now, unfortunately.

potent ferry
#

sorry 😦

north stream
#

No worries, just explaining why I'm not able to help that much at the moment.

potent ferry
#

Thanks. I hope things get bettet for you

north stream
#

I'm dealing with it, but it was an unwanted surprise and a lot of time and effort I hadn't planned on.

velvet charm
#

@potent ferry , why do you need to do that hard thing, you can use some switches/buttons and then in your code you can count how fast they are pressed (while you walking) and based on this speed turn your servo!

potent ferry
#

Hi @velvet charm are u suggesting to use pressure sensors instead of accelerometers ?

#

I use pressure sensors for backward movements and lateral movements. The problem that i would imagine facing if using pressure sensors for walking accross a room or/and walking in place and/or running in place might be

  1. what happens when i lift the foot a little to reach the pressure sensors that i mounted in the inner part of my shoe and also the pressure sensors that i mounted on the back of my shoes?

  2. are there affordable pressure sensors that would support that intense pressing of body weight for walking and running over them?

What do you think about the 2 points above, keepimg in mind the whole setup i weote in the sketches?

#

This is for the forward movement and for the backward movements i use 2 pressure sensors , similar as i use rhem for lateral movements . In this video i go backwards just because i mounted the motors the opposite way. That was an easy fix. I move forward in games with accelerometers but the way my code is setup , does not work well when passing from slow walk to run and the opposite

#

Because my arduino code is set up on accelerometer angles and not on accelerometer frequency

#

lso in this last vidoe, this is running the old version of the code. Now the code is a little different

velvet charm
#

@potent ferry , yes, it is easier to code

potent ferry
#

but how do you handle the fact that I am lifting the feet for also pressing sensors for lateral movements and backward movements

#

?

#

how can I then use the pressure sensors to walk and run ?

#

what pressure sensor can handle my weight and gravity of stepping hard when running on it ?

velvet charm
#

Ok, my idea isn’t very good

potent ferry
#

no no, maybe you have a solution for that

#

This method on this video though has limitations due to software, so to differentiate walk and run, i need to push a button to activate and deactivate a code. That is due to software limitations that I can bypass instaed through the arduino method I am working on

#

I want to investigate more your suggestion. I am not dumping it

potent ferry
#

Anyone, i have a question about accelerometers and arduino.

Would it be possible to connect 4 accelerometers to 1 arduino, to control 1 servomotor ?

Right now i have 2 accelerometers connected to 1 arduino, to control 1 servomotor.

odd fjord
#

@potent ferry Assuming they are I2C devices then they must have unique addresses. Which accelerometer are you using? If you cant set 4 different addresses, you should be able to use an I2C multiplexer like this one: https://www.adafruit.com/product/2717

acoustic nebula
#

or do it in software with my multi_i2c library

#

most accelerometers have 3 address lines exposed, so you could have up to 8 unique addresses

potent raven
#

hello, i have a question.

can esp32 use ble(scan) while deep sleep?

(i want esp32 to wake up when esp32 scan ble_server)

acoustic nebula
#

the BT radio is directly driven by the ESP32 CPU, so that doesn't sound possible

late shoal
#

Does the feather count as arduino?

surreal pawn
#

@late shoal are you programming it from the arduino application?

median mica
#

Has anyone had trouble uploading code from Arduino to a Circuitplayground Classic? I’m getting the same error. Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding avrdude: ser_recv(): read error: Device not configured. I’m using a good usb cable. I’m able to upload to my other boards. I’ve updated my boards and libraries. I’m on a Mac 10.15.1. Arduino version 1.8.10

north stream
#

Hmm, I don't remember what programmer the Circuit Playground Classic uses, but I don't think it's the butterfly. What do you have the board and programmer set to?

fiery lichen
#

So I’ve powered neopixels off feathers before by putting the BAT pin to the +5v on the neopixel to avoid the 3.3v regulator. I’m looking at the schematic layout and it says BAT is just a connection running to the positive battery terminal. What’s the current limit on the trace? What if I want to draw 2amps on neopixels. How could I safely draw battery power off a 6600 maH pack. Clearly the battery is fine, but im concerned the trace isn’t designed for that. Should I splice in a larger gauge wire between the jst connector and the battery on the positive wire?

acoustic nebula
#

power the LEDs from a separate supply and link the grounds together from the 2 different sources of power

median mica
#

@north stream I was trying some Neopixel code, but now I’m just using the basic blink sketch included in the Circuitplayground Arduino example. So, the code isn’t an issue. The programmer is set to USBtinyISP. I didn’t think that setting affected programing this board.

fiery lichen
#

Bitbank, but using the on board battery charger would be very nice

acoustic nebula
#

you can drive LED strips with low current if you set them to minimum brightness 🙂

#

the voltage regulators on development boards usually expect to supply in the 150-300mA range. Some of the newer Arduinos can supply up to 1.2A

#

for long LED strips you need a dedicated high current supply

fiery lichen
#

Well that’s why I’m hooking to the BAT pin to bypass the voltage regulator 🙂

acoustic nebula
#

Oh - I think I get what you're saying.

#

I guess it depends on how many LEDs you're going to drive and how bright

#

The battery voltage may sag a bit due to the current driving the LEDs and the trace may not support too much current

north stream
#

You could run separate leads from the battery to the Feather and the LEDs, then you could use the on-board battery charger and not worry about overloading the traces on the board with LED current. It's a little external wiring, but should do what you want.

fiery lichen
#

That’s exactly what I was thinking after sleeping on it. Wasn’t sure it was “legal” or I was missing something that would cause the battery to go kaboom 🙂 I hate getting lithium ions in my eyes 🙂

north stream
#

It's just moving from routing current through a trace on the board to routing current through a wire, the real difference being that the wire can carry more current safely.

#

I often find I'll come up with a better idea when I come back to a problem with fresh eyes.

fiery lichen
#

One other thing. I know neopixels can pull 60mA at full white at full power. Is that a 5v statement?

If I’m powering them with 3.7v battery, is the current draw the same even though they can’t get as bright at “full power” due to the lower voltage? Just trying to size my batteries and wires correctly

north stream
#

They'll get essentially as bright even at 3.7V, so you should still plan for 60mA per pixel (80mA for RGBW pixels).

potent ferry
#

Hi @odd fjord . I am using two Gy-521 MPU-6050 but i also have two ADXL345

#

Hi @acoustic nebula , I am using two Gy-521 MPU-6050 but i also have two ADXL345.

#

The two mpu-6050 i am using, are running in my arduino code as separate accelermoters with y1 and y2 values output when i move them and rotaring the same servomotor.

How can i connect on an arduino uno the other 2 accelerometers so that they output y3 and y4 and they can control the same 1 servomotor tb3at the other 2 accelerometers control ?

north stream
#

The accelerometer doesn't control the servo, the Arduino controls the servo. You just need to decide what effect you want the additional inputs have on the behavior of the servo.

acoustic nebula
#

You can set unique addresses to each

#

the little dev boards usually expose at least 1 address select line

#

let me double check mine...

#

Yes, the GY-521 exposes the AD0 line. Tie it high for one address and low for the other

#

I don't have any ADXL345's handy, but I think they have the same kind of arrangement

potent ferry
#

I would use the 4 accelerometers the same way i am using 2. Pratically 2 woukd control the walking and 2 the running. Meaning 2 acceelrometers would rotate the servo of a low angle and the other 2 would rotate the same servo toward a bigger angle.

#

Lets say angle 90 degree is the servo at its center. 2 accelerometers would control the rotation from 90 degree to 78 degree, and the other 2 accelerometers would control the rotation of the same servo from 90 degree to 70 degree or from 78 degree to 70.

median mica
#

The old code on the CircuitPlayground still runs. I’ve been working at it and hit the buttons. They still light up the neopixels in a pattern.

fiery lichen
#

Doh one last thing, I’ve always added a beefy capacitor across the + to - for when I power neopixels off a wall power supply. Is it necessary for a big capacitor if powering via a battery?

north stream
#

The capacitor will be helpful there too.

potent ferry
#

This is how i am wirimg on the arduino, 2 accelerometers and 1 servo. What the other 2 accelerometers should use?

#

GY6050 gyro1(0x68);
GY6050 gyro2(0x69);

acoustic nebula
#

I can't see from your photo, but I2C is a bus; all devices share the same SDA/SCL lines

#

or you can use my Multi_BitBang library to talk to I2C devices on any GPIO pins and have multiple devices with the same address

woven fox
#

Good Morning/afternoon folks. I have a noob question. Int is a global integer, so does this mean that #define is specific to a library?

woven mica
#

int can be either global or local, depending on where you declare it

woven fox
#

Ok. So when a prhase has #, does it mean it’s function is defined in a library?

woven mica
#

If it has a #, it means it is a preprocessor instruction, most likely a macro

#

or a constant

woven fox
#

O nice! Ty so much!

#

That answers everything

vague kettle
#

overthinking the code again. time for a break

#

string handling is hard =/

pine bramble
#

I'm writing my own string handling primitives. ;)

#

(and I hate it) (haha)

vague kettle
#

🙂

pine bramble
#

Actually I'm fascinated.

#

But a little goes a long way.

vague kettle
#

good to see you again sir 🙂

pine bramble
#

Yeah, you too.

#

My memory is terrible and I don't use avatars here so I have to remember people on a rather sketchy basis.

#

Oh you're the one who said 'I'm an old'

vague kettle
#

im the guy making a space station pointer, and you seemed to be a space nerd too. i mentioned using celestrak for my TLE data and asked if there was a better source, and you said it was the best place to be

#

yea, im also an old lol

pine bramble
#

I've been repeating that one all week

vague kettle
#

🙂

pine bramble
#

Not an old man. An old. I think that's uproariously funny.

vague kettle
#

yup lol

#

sadly i didnt invent it. just repeating sumn i thought was funny as well

pine bramble
#

I appreciate the recap, it helps a lot!

#

Yeah I thought you were a Brit but then you said stuff that made that less likely.

vague kettle
#

nope. im in california, about 1hr east of san francisco. just far enuf to keep the hippies at bay

pine bramble
#

Hahah.

#

An hour east is fairly inland.

vague kettle
#

there is a large hill/pass between us. the super crazy ones tend to stay on that side

pine bramble
#

I'm about an hour from the ocean.

vague kettle
#

im still a california hippie, but not nearly as crazy as those other folks lol

#

which ocean?

pine bramble
#

Culture is weird in what it spreads and how it spreads it. I'm in CT so the ocean is the Atlantic.

vague kettle
#

gotcha

pine bramble
#

I have not visited the Pacific Ocean.

#

Went to Yurrup in like 1977 or so. Canada near the border with the USA in the East.

vague kettle
#

farthest east ive gone is the iowa illinois border, saw the mississippi river

#

davenport ia i think?

pine bramble
#

I've probably been to about 35 states and lived in Colorado, twice.

vague kettle
#

i travelled around climbing radio towers for a few years. spent around 6months in omaha, NE. a few months around iowa + illinois. never got to see chicago tho

#

then we headed back and stayed in dallas, tx for a while

#

lots of good stories, but im glad im done with towers lol

pine bramble
#

I'm going to go out and do that thing you do and then come back inside the house. ;)

vague kettle
#

not a bad idea, think ill join ya. see you in 8mins or so

pine bramble
#

(they got the hidden meaning!) spy vs spy

vague kettle
#

so... ive got a 2x16 char display, and i want to show 16 lines of data on it. the plan is to show + update 2 lines of info for 5seconds, then switch to 2 diff lines of info and keep it updated for 5secs. so a state machine

#

next, cram the info into 1x16...

#

identifier text will be stored in code, example time/date is Tm: /Dt:

#

my space tracking functions return between 0.000 and 359.999. so i need to intelligently cut off some decimal points. im more comfy with printf than i am with cout, but im open to using either. gunna start with printf since its more familiar

#

the sprintf and snprintf functions want to add a 0 terminator to the end of the string, and im pretty sure my 2x16 display wont like it. so either i chop it off before it gets sent... or i use sprintf() on each value, and use strcat to add it to a char[] manually

#

Az: 200 El: 134

north stream
#

When I first read that, I was imagining using the display as a 16-row bar chart, which might be possible, even though I later realized that was not what you were describing.

vague kettle
#

i just cursed? got a warning

#

i can use this display to show a bar graph

north stream
#

Most of the display libraries accept a simple null-terminated string, so sprintf() may be the way to go.

vague kettle
#

but no i just want text

#

lets try again...

#

AZ: 359 EL: 180

#

thats 16. no decimals. i may want decimals

#

AZ: 359.000

#

EL: 179.999

north stream
#

Seems simple enough.

vague kettle
#

just means a bigger state machine, no biggue

#

*biggie

#

also, wouldnt have to worry about string formatting, and chopping + strcat()'ing a bunch of crud together

#

i think thats gunna be my answer

#

instead of a 4state machine, it has 8steps now

north stream
#

Fortunately all the steps do pretty much the same thing, so a little arithmetic will find the current set of numbers to display, and can call a common display routine.

vague kettle
#

yup

#

update the current time. do the orbital math. if state1, show time/date. if state2, show azimuth/elevation. if state3, show range/speed

#

if 5 seconds have elapsed, state++

north stream
#

Looks good to me.

pine bramble
#

Plate o Shrimp - that was a year ago. ;)

#

Probably a screencap of a DOSEMU window.

vague kettle
#

i used things like that to confirm my numbers

#

my numbers look solid

pine bramble
vague kettle
#

the 'Program 2' header. i have that info + more, working. they formatted it pretty for the website, but i gotta handle it myself

#

overthinking again. 8lines of info. not 16

#

still only need a 4state machine

vague kettle
#

that webpage reads like the sdp model works, and i can track planets too, which is why i chose it. but i havent tried it yet. only playing with satellites for now

pine bramble
#

I've accidentally viewed satellites in my (old) telescope (which I no longer have).

#

It's very weird to see the white dot move at that rate in a telescope.

vague kettle
#

ive owned a nice telescope. in the early 80's my uncle had a cheap-o that let me see craters on the moon. ive also been to a nerd night at a local observatory, and i got to see a blurry image of saturn

#

*ive NEVER owned a nice telescope

pine bramble
#

They had a good one at the planetarium and took us up to the roof to view through it after the planetarium show.

vague kettle
#

ive seen the ISS pass overhead with my nekkid eye tho

pine bramble
#

They said they had a cement pillar built from the rock below the building and the building was designed to not touch the pillar. :)

vague kettle
#

not touching the foundation? i would think they want very solid foundation. is that for vibration?

#

gotta be

#

gunna go down for a cig, and grab a beer while im out. be back in like 10-15

pine bramble
#

Hehe.

#

I envisioned it as like an elevator shaft - a space in the middle of the building, spanning many floors.

#

There was no shake in the image at all, through that telescope.

#

I showed my mother Saturn in a 4" telescope. She became very afraid.

#

I had to explain to her that it was there long before she was born, and no, it wasn't going to come crashing down on us.

#

I saw Saturn when I was about nine or ten with thirty other students, so that kind of thought never had crossed my mind.

#

April 8, 2024

vague kettle
#

i think i was 9 or 10 when i saw saturn too

#

no shake, and there was an actual eyepiece for me to use. telescopes these days dont usually have an eyepiece

#

all i remember is that it was blurry. i saw that there were rings around it, but it was pretty much just a brown blob lol

pine bramble
#

I would have bet money that was 1969 not 1970. ;)

vague kettle
#

lol

pine bramble
#

We were allowed outdoors during the event, unsupervised. ;)

vague kettle
#

to be fair, im only 37. not THAT old

#

way older than the usual chatroom folk i encounter tho, so im still 'an old'

pine bramble
#

Misuse of 'old' five yards, defense.

vague kettle
#

lol

pine bramble
#

I remember .. um .. things .. about age 37 so sure, go ahead. ;)

vague kettle
#

most of the chatrooms i encounter, im easily a decade older than most, so 'an old' is fair in this context

#

i know you have me beat tho 🙂

pine bramble
#

Pretty sure by 27 you can fly fighter jets for the Air Force, if that's any help.

vague kettle
#

27 seems high

#

enlist at 18, finish classes by 20-22, then start the experience/flight hours phase

#

im not .mil, so just guessing

#

18 you can smoke and tell ur parents 'no'. 21 you can drink. 25 you can rent a car, and buy liquor in jamaica. after that its all downhill

pine bramble
#

It's kind of weird because the Flight Line is its own subculture. I was sent over there one day and was surprised to see they didn't wear the same uniforms we did.

vague kettle
#

i was climbing radio towers 31-34, and i was too old for it

#

i was better than my younger team, but its still more of a young mans sport

pine bramble
#

Hehe, it's pretty high up there.

vague kettle
#

my average worksite was 200-300ft. highest job was 600. highest tower i ever climbed was 800-820ish, and i went to the top just to say i did it

#

ill claim 800ft highest climbed lol

#

highest work performed was 600 tho

#

job is done @ 600ft. upload photos, wait for sprint/at&t to approve it. im gunna head to the top while we wait, just for a selfie

#

lol

lilac mountain
#

when i unplug and then replug the USB cable that goes to my Metro Mini, whatever was on the 8x8 LED matrix i have hooked up to it before unplugging it is redrawn to the display before my sketch actually gets reloaded into memory.

#

i'm already drawing a "splash screen" of sorts to the display in the setup() function of every sketch, so it'd be nice if i could stop the old draw from happening

#

so is there a way to make the display come up empty immediately after power-up? or is this the result of some deep-set Arduino behavior i'll probably have to live with

surreal pawn
#

It’s not Arduino behavior. Do you have a link to the led matrix you’re using?

lilac mountain
surreal pawn
#

It doesn’t look like the library does anything to the display if you don’t ask it to. You could clear or set brightness to zero in setup() but that is about the best you can do

#

The display will still show the old image before setup()

lilac mountain
#

yeah, okay

#

although that did help me figure something out. apparently setting matrix brightness to zero immediately after a call to matrix.begin(0x70) will draw the old image but only for a small fraction of a second

#

so that probably works better than anything else :p

rocky igloo
#

The datasheet says that the display is disabled on powerup. It's getting turned on by the begin() function call as part of blinkRate().

#

You could try commenting out the call to blinkRate() in Adafruit_LEDBackpack.cpp, clearing the display, and then enabling the LEDs yourself.

#

@lilac mountain

lilac mountain
#

good call, i'll try that tomorrow

#

in any case thanks both @surreal pawn @rocky igloo

wind drift
#

How can I change the brightness of the neopixel?

#

I am getting blinded

#

nevermind got it

north stream
#

If you're using the NeoPixel library, the .setBrightness() method ought to help.

north kelp
#

@wind drift @north stream It’s often more performant and more accurate to do it yourself, instead, by multiplying your RGB values by a brightness fraction.

wind drift
#

Yes I lowered my rgb value

#

But is there a limit to how dark it can be?

#

I went from between 50 and 25% I did not notice much difference

north stream
north kelp
#

@wind drift Yep! The perceived brightness is non-linear. You can often save a lot of power by scaling your RGB values way down. The gamma correction above is good reading.

pine bramble
#

I have to wonder if the bootloader can be made to send a couple of commands to the running target system (say: RUN vs STOP).

#

Selectable at runtime via the /RESET PB switch - similar to double-clicking and what that does, now.

#

Or, is it more like a GOTO <addrs> with zero effect on the future history of the system, after <addrs> is read (and the code there, executed).

lilac mountain
#

ughhhhh i've been fighting with this for so long i might as well just ask

#

how can i set up a uint8_t array in a .h file, then actually set its value within the corresponding .cpp file?

#

the catch is that it has to be initialized with static const uint8_t PROGMEM

#

(i think 😬 )

#

trying to set myself up to be able call the drawBitmap() function of the Adafruit GFX library, if that helps this make more sense

velvet charm
#

I’m not an expert but you made it a constant?

lilac mountain
#

it has to be a constant, otherwise i can't load it into PROGMEM

#

and setting its value inside the public block of the .h file doesn't seem to work

north kelp
#

@lilac mountain Which microcontroller are you using? I believe that you can't set PROGMEM variables at runtime, only at compile time. But something like an M0 or M4 board, especially an Express version, with onboard SPI flash, would give you more flexibility.

surreal pawn
#

you can declare it extern in your .h file then implement it in your .cpp file

#

this way you can refer to the global variable from multiple cpp files but it only has one storage location: corresponding to the one in your cpp file where you actually initialize it

lilac mountain
#

i'm using the Metro Mini @north kelp

north kelp
#

Can you try what @surreal pawn suggests? I haven't tried it, but it sounds like a good idea!

rocky igloo
#

sketch.ino ```C
#include <avr/pgmspace.h>
#include "mem.h"

void setup() {
Serial.begin(9600);
Serial.println((const uint8_t) pgm_read_byte(&array[2]));
}

void loop() {
}```

#

mem.h C extern const uint8_t PROGMEM array[];

#

mem.cpp ```C
#include <Arduino.h>

extern const uint8_t PROGMEM array[] = {1, 2, 3, 4, 5, 6, 7, 8};```

#

Output 3

lilac mountain
#

let's see

#

sketch.ino

#include <Omega.h>

Omega omega = Omega();

void setup() {
  omega.init();
  omega.splash();
}

void loop() {
}```
#

Omega.cpp

Omega::Omega() {
  extern const uint8_t PROGMEM _splash[] = {
    B00000000,
    B00011000,
    B00100100,
    B01000010,
    B01000010,
    B00100100,
    B01100110,
    B00000000
  };
}```
#

Omega.h

class Omega {
  private:
    extern const uint8_t PROGMEM _splash[];
};```
#

i'm writing it like a library

surreal pawn
#

you've declared it as an instance member variable inside an instance of the class Omega. I don't think you can use PROGMEM that way

lilac mountain
#
     extern const uint8_t _splash[];
                                  ^

C:\Users\sporeball\Documents\Arduino\libraries\Omega/Omega.h:29:42: error: flexible array member 'Omega::_splash' not at end of 'class Omega'
C:\Users\sporeball\Documents\Arduino\libraries\Omega/Omega.h: In constructor 'constexpr Omega::Omega(Omega&&)':
C:\Users\sporeball\Documents\Arduino\libraries\Omega/Omega.h:29:42: error: initializer for flexible array member 'const uint8_t Omega::_splash []'
C:\Users\sporeball\Documents\Documents\Code\GitHub\project-omega\sketches\Snake\Snake.ino: At global scope:
C:\Users\sporeball\Documents\Documents\Code\GitHub\project-omega\sketches\Snake\Snake.ino:3:21: note: synthesized method 'constexpr Omega::Omega(Omega&&)' first required here 
 Omega omega = Omega();
                     ^```
#

knocked PROGMEM out of both of the declarations and it still throws this ^

surreal pawn
#

yeah, it will have to be a pointer in your header file

lilac mountain
#

i.e.? @surreal pawn

surreal pawn
#

header file:
extern const uint8_t * const sfx;

#

cpp file:

#

const uint8_t sfx_raw[4352] PROGMEM = {stuff} const uint8_t * const sfx = sfx_raw;

#

if you can copy the size in the header and cpp file then you can just make it an extern array of fixed size but in my case I can't.

#

so that'd be something like:

#

foo.h global const declaration:
extern const uint8_t myarray[128];
foo.cpp global storage + initialization:
const uint8_t myarray[128] PROGMEM = {stuff};

lilac mountain
#

it's still throwing the whole storage class specified for '_splash' thing

north stream
#

extern const uint8_t * _splash; maybe

lilac mountain
#

no dice

north stream
#

Storage class error still or some other error?

lilac mountain
#

storage class error

north stream
#

Hrm. Maybe punt extern and/or const, those are the only storage class modifiers left: it could be that using old C-style modifiers doesn't play nicely with C++ style classes.

surreal pawn
#

are you still trying to declare this inside your class?

lilac mountain
#

yeah

rocky igloo
#

I needed extern const in the declaration in both the .h and .cpp files. It wouldn't compile without them.

lilac mountain
#

without const or extern the Adafruit libraries are throwing 5 errors at once

surreal pawn
#

I don't think you can declare progmem instance members

lilac mountain
#

aaand we're back to the storage error instead

#

even without PROGMEM ^

surreal pawn
#

yeah because your class needs to define exactly how large that array is because it's an instance member

lilac mountain
#

it does though?

#

i passed an 8 between the square brackets

rocky igloo
#

Not sure where you're code is now @lilac mountain but up above you've got _splash[] inside the constructor member function Omega::Omega(). That seems unlikely to work.

lilac mountain
#

guess i get to declare static const uint8_t PROGMEM splashData[8] solely within Omega::splash()

#

well this was a rollercoaster from start to finish

#

and i can still write to the display by making it public, then using omega.matrix...

#

this works

#

one more function to write and then i think i'll be finished with the library 🎉

#

thanks everyone for helping out owo

surreal pawn
#

@lilac mountain if it's not needed outside your class it could just live in the cpp file only as a global there... yeah similar to making it a static variable inside of the function

#

.h

#pragma once
class Omega
{
public:
    Omega();
    void init();
    void splash();
};

.cpp

#include <Omega.h>
#include <stdint.h> // uint8_t
#include <avr/pgmspace.h> // PROGMEM
// only available in this cpp file:
const uint8_t _splash[] PROGMEM  = {
0b00000000,
0b00011000,
0b00100100,
0b01000010,
0b01000010,
0b00100100,
0b01100110,
0b00000000
};

Omega::Omega() {
}
void Omega::init() {
}
void Omega::splash() {
// use _splash here
}
rocky igloo
#

Unless you're expecting to have multiple Omega object instances and different bitmap data for each of them, where the data is declared isn't much of an issue.

surreal pawn
#

I'm not using Arduino.app so B0000000 didn't build for me

lilac mountain
#

ahh gotcha

lilac mountain
#

that is pretty much what i'm doing now actually

#

although i'll note that if i don't declare _splash[] as a static then the screen outputs a bunch of garbage data o.o @surreal pawn

#

odd

surreal pawn
#

I don't know what your code looks like at that point, but I'd bet you've got two different storage locations with the same name that aren't the same place

#

as in, one is a local variable of that function, and another is an instance or global variable you never initialize

lilac mountain
#

i did narrow it down. it only seems to output garbage data if i declare _splash[] as a non-static const within Omega::splash()

#

any other style seems to work fine

#

now we know i guess :p

devout sun
#

i am 100% new to all this! is it possible to fry parts going under amp or could I have just gotten a bad part; am i doing something else wrong? i think, i had a node mcu (i am pretty sure the node mcu is fried because it won't power up or connect when plugged into computer anymore) and 5v led powerstrip, go out on me... it was only being supplied 1amp, at the time. i have a 12volt power supply with a 12v-5v (3amp, according to spec) step down going to 5v led strips... 5v/3 amp would probably be perfect (i think) but i only get 5v/1amp. would my led strip just not work in this case? would a proper 5v power supply fix my problem?

surreal pawn
#

yes, connecting 5v or 12v on the wrong nodemcu pin could toast it with less than 1 amp of current

#

stepping down from mains to 12V then 12V to 5V isn't so bad that you should avoid it

devout sun
#

i didn't connect on the wrong pin

#

i had it stepped down, before that

surreal pawn
#

you can definitely connect more 5V neopixels than you can drive with only 3 amps at 5V. I think very roughly that'd be over a hundred though

devout sun
#

i have a 5v power supply and a new led strip coming... i am optimistic i'll get it working then.

#

i am learning

surreal pawn
#

huh, how long has platformio had the "inspect" feature?

#

someone finally built the breakdown of "where is my ram and flash going" and it's already in platformio

simple horizon
#

Does anyone know how I can get the battery percentage on an itsy bitsy?

surreal pawn
#

some of the boards the arcada library supports have an analog input used as a battery sensor

#

the resistor divider is because a single cell lipo is often above the 3.3V for the samd21 logic level

#

I don't know if you're using the 5V itsy bitsy or the 3.3V one

wind drift
#

I sometimes have a problem with the arduino ide

#

It shows multiple same com ports

wind drift
#

Got a code question again.

I want to have my barcode scanner scan while I hold a button down.
However when I press the button just once it should print something for around 5 seconds and then stop

#

during the 5 seconds if I hold the button again it should scan again

#

and so on

#
Serial.println("scanning");
  }```
#


  while (digitalRead(button) == LOW) {
    Serial.println("scanning");
    ButtonActive = true;
  }


  if (ButtonActive == true) {
    lastScanButtonTime = millis();
    currentScanButtonTime = millis();

    while (currentScanButtonTime - lastScanButtonTime < 500) {

      Serial.println("RFID");
      currentScanButtonTime = millis();
      ButtonActive = false;
      while (digitalRead(button) == LOW) {
        Serial.println("scanning");
        ButtonActive = true;
      }
    }
  } 
 }```
#

Okay kinda got it to work

north stream
#
#define SECONDS(x)    (x * 1000)

static bool        scanning = false;
static unsigned long    endscan;

void loop()
{
  unsigned long curtime = millis();

  if (digitalRead(button) == LOW) {
    if (!scanning) {
      Serial.println("scanning");
      scanning = true;
    }

    endscan = curtime + SECONDS(5);
  }

  if (scanning && (curtime > endscan)) {
    Serial.println("end scanning");
    scanning = false;
  }
}
wind drift
#

Thanks - but it's not exactly the one I am looking for.

While holding the button it should loop and print "scanning"

If I only tap the button once it should NOT print scanning
Instead it should loop for 5 seconds and keep printing "RFID"

#

But if I hold the button during the 5 seconds it should print the scanning like before

north stream
#

Whoops, I misunderstood

wind drift
#

@north stream ```void loop() {

startScanTime = millis();

while (digitalRead(button) == LOW) {
Serial.println("scanning");
ButtonActive = true;
lastScanButtonTime = millis();
}

if ((ButtonActive == true) && (lastScanButtonTime - startScanTime > 1)) {

currentScanButtonTime = millis();

while (currentScanButtonTime - lastScanButtonTime < 500) {

  Serial.println("RFID");
  currentScanButtonTime = millis();
  ButtonActive = false;
  while (digitalRead(button) == LOW) {
    Serial.println("scanning");
    ButtonActive = true;
  }
}

}
}```

#

I gave this one a try

#

but not really working

#

It still prints the rfid even after a long press

#

if ((ButtonActive == true) && (lastScanButtonTime - startScanTime > 1))

north stream
#

I don't really follow what your intended behavior is.

wind drift
#

Well basically I want to scan a barcode while I am pressing the button.
And when I just tap the button it should activate an RFID scanner and scan for a period of 5 seconds

#

I thought if ((ButtonActive == true) && (lastScanButtonTime - startScanTime > 1)) could handle the part where it checks if the button has only been tapped once

north stream
#

So when the button is first depressed, it goes into "scan barcode" mode. Then when it's released, it should switch to "RFID" mode and stay there for 5 seconds, then go to idle?

wind drift
#

While the button is pressed down it should be in scan barcode mode. When you release it it should idle.
When you only tap the button for a second it should go into RFID mode and scan for 5 seconds. Then should idle

#

With my current setup it goes into RFID mode even if I have pressed the button for a long time

wind drift
#

And I have one other problem

#

the barcode and rfid scanner both use SoftwareSerial

#

but it does not respond when I try the islistening command

north stream
#
#define SECONDS(x)    (x * 1000)    // convert seconds to milliseconds
#define SHORTPRESS    700        // max time for a short press

static bool             scanning = false;
static bool        rfid = false;
static unsigned long    startpress;
static unsigned long    stoprfid;

void loop()
{
  unsigned long curtime = millis();

  if (digitalRead(button) == LOW) {
    // button pressed, go to barcode scanning mode
    if (!scanning) {
      Serial.println("start barcode scanning");
      scanning = true;
      startpress = curtime;
    }
  }

  if (scanning) {
    if (digitalRead(button) == HIGH) {
      // button released
      Serial.println("stop barcode scanning");
      scanning = false;
      if ((curtime - startpress) < SHORTPRESS) {
        // short press, switch to RFID mode
        Serial.println("start RFID scanning")
        rfid = true;
        stoprfid = curtime + SECONDS(5);
      }
    }
  }

  if (rfid && (curtime > stoprfid)) {
    Serial.println("end RFID scanning");
    rfid = false;
  }
}
#

Does the .isListening() method not return or what?

wind drift
#

Yes it does not return any print

#

but I also tried the exact same example code

#

my arduino crashes when I try to open the terminal

north stream
#

Maybe there's a bug in SoftwareSerial or your Arduino is an unusual one?

wind drift
#

Adafruit Feather nRF52840 Express

#

Error setting serial port parameters: 9,600 N 8 1

#

22:52:09.841 -> stop barcode scanning
22:52:09.841 -> start RFID scanning
22:52:10.320 -> start barcode scanning
22:52:10.561 -> stop barcode scanning
22:52:10.561 -> start RFID scanning
22:52:10.561 -> start barcode scanning
22:52:10.561 -> stop barcode scanning
22:52:10.561 -> start RFID scanning
22:52:11.072 -> start barcode scanning
22:52:11.209 -> stop barcode scanning
22:52:11.209 -> start RFID scanning
22:52:16.221 -> end RFID scanning

#

Is what I get with the code above

#

when I press/release

rough torrent
#

Hi there, I have some really long (150+ lines) Arduino code that seems to be very inefficient too. Is there anyway I can shorten the code/make more efficient?
http://txt.do/1o0mf

north kelp
#

@north stream @wind drift SoftwareSerial may not be a reliable option on nRF52840. It isn't on nRF52832. See this Forums post:
https://forums.adafruit.com/viewtopic.php?f=54&t=153712&p=758466#p758466

…and this issue discussion:
https://github.com/adafruit/Adafruit_nRF52_Arduino/issues/243

worn bison
#

any idea on how to check polling rate of arduino on windows?

north kelp
#

What are you polling, @worn bison?

worn bison
#

an arduino based game controller (DDR)

#

needing 1khz polling.

#

i know the sketch is good because i verified it some time ago in linux with evhz but now I am using windows because (reasons) and am looking for a way to verify polling in this environment @north kelp

north kelp
worn bison
#

i have ds4windows but the controller doesnt show up

#

i used to use this

#

but i think someone had to help me tweak it slightly to work with the arduino keyboard based controller

#

then i had to mash the buttons and look for polling rates at or around 1000hz

wind drift
#

I sort of got my problem with my barcode and rfid scanner working

#

But I am a bit confused why the print order is not correct?

#

after 'scanning' it should print the barcode

odd fjord
#

how many times does it go through that code during the 50 milliseconds it waits before printing the barcode. Each time does, it will print the lines you see.

wind drift
#

Ah I see what you mean

wind drift
#

Okay another problem

#
startScanTime = millis();

  if (digitalRead(interruptPin) == LOW) {

    lastScanButtonTime = millis();
    pinMode(interruptPin, INPUT);

    unsigned long curtime = millis();

barCodeSerial.listen();

  if (barCodeSerial.isListening()) {
  //  Serial.println("scanning");

  lastReadTime = millis();
 
  while(barCodeSerial.available()){
   //   delay(5);

    code += (char)barCodeSerial.read();
    //Serial.println(code);
    inString = true;
    ButtonActive = true;   
      }
  }
}
    uint32_t curReadTime = millis();
        
if (ButtonActive == true && inString == true && curReadTime - lastReadTime > 10) {

if (scanmode == "adding"){
  Serial.println(scanmode);
  Serial.println("BarcodeID:");
  Serial.println(code);
  code = "";
  inString = false;
  ButtonActive = false;
 
}```
#

So currently the barcode is reading fine

#

What I would like to happen is that when I press the button AND there was no code pasted it should print something

#

But I am not sure where to put the code

#

I tried to put it as an else behind isListening but it didn't help

north stream
#

Probably check for the button no longer active and inString still false?

wind drift
#

Ah yes got it to work now

#

Okay - last thing but I am not sure how to fix that.

Currently it will print the barcode after I have released the button. Is there any way to let it print when it received the whole code even when I am still holding the button. (I know that the light turns off on the barcode scanner when it has read the code

#

at the moment I only have this one connected

north stream
#

If the barcode reader sends some sort of "end of code" character (like a null or carriage return), you can check for that and print it then.

#

Alternatively, you can set a timer when you receive a character and when a certain amount of time has elapsed without any new characters, go ahead and print the barcode

wind drift
#

I cannot see any special character from the terminal unfortunately. (Unless it's somehow invisible?)
I think the second option will be a bit complicated if it's a longer barcode, no?

#

Maybe I can somehow use the pin 10 LED to detect if it scanned something?

#

Right now the LED at pin10 is ON when in idle. And when it scanned it turns off for a second.

river osprey
#

I hope it's OK to share this here. A bunch of people have helped me over the past week or two on LED based project I'm working on, and it's finally done, so I created a demo video https://www.youtube.com/watch?v=aaXFCma1wlk a link to the code can be found in the description. Thank you! (if there's a better place for me to post, just let me know)

wind drift
#

Weird the beeper also is on in idle, but off when it scanned

#

How can I reverse that?

wind drift
#

A transistor I assume?

north stream
#

Might be able to do it in code, but a transistor is also a possibility.

#

With the "time since last character received" algorithm, the length of the barcode is not important.

wind drift
north stream
#

The LED may not be in synch with the serial data, I'd stick with the .available() method

#

I suspect the -1 results are "read failed because of no data"

wind drift
#

Okay - I thought maybe I can determine the end character here

north stream
#

Most barcode readers are configurable as to what (if anything) they send for an "end of barcode" delimiter.

#

Failing that, the "time since last character received" approach should work.

wind drift
#

"(Level)Key Holding
Press the button to trigger the reading, release the button to end the reading. Reading success or reading time over a single reading time will end the reading.
"

north stream
#
#define MAXBARCODEDELAY    70

unsigned long    curtime = millis();
bool        waiting = true;

while (buttonpressed && (waiting || (curtime < timeout)) {
  if (barCodeSerial.available()) {
    code += barCodeSerial.read();
    waiting = false;
    timeout = curtime + MAXBARCODEDELAY;
  }
}
wind drift
#

Not sure if I can find the final character in here

north stream
#

Then use the "look for pause between characters" approach.

wind drift
#

Maybe this one?

wind drift
#

Hm I got a prefix now

north stream
#

Looks like the right ones.

wind drift
#

page 66

#

and it works

#

but for the suffix I guess I am doing something wrong

#

I scan these

#

but not helping somehow

north stream
#

If I read it right, you need to scan the Suffix 1 code (50C006) followed by four numeric digits to specify the code to send. Then scan the transmission format code for data + suffix1 (20C1001). Then it should send the barcode data, followed by the character described by the 4 digits you scanned.

#

Perhaps 50C006 + 0 + 0 + 1 + 0 to set suffix 1 to a linefeed.

wind drift
#

Ah I think you are right

#

I only did one number

north stream
#

I gleaned that from the wording "To set these values, scan a four-digit number (i.e. four bar codes)"

#

Apparently there's a way to do it via serial commands as well, but scanning bar codes seems simple enough.

wind drift
#

Hm just tried again but it does not seem to work

#

not sure if I need some kind of 'save' function after the 4 codes

pine bramble
#

I'm making a project that uses the vs1053 adafruit shield to play music for a spinning christmas tree I made. I have LEDS attached to the tree, but I want them to interact with the music. For example, the lower tier of lights would pulse every time the bass is hit on a drum set in a song, and the upper tier would blink everytime the hi-hat is played. How would I got about doing this? In my head it seems simple but I don't know how to code it. Any help would be appreciated.

Here's a link to a resource for vs1053 Class Reference https://mpflaga.github.io/Arduino_Library-vs1053_for_SdFat/classvs1053.html

little nimbus
#

Hey guys! I want to make a physical youtuber subscriber clock for one of my friends.. Someone told me that it may not be possible anymore with youtube's new subscriber display methods so wanted to ask you for any advice!! how should I go about it now? or is it just not possible! (I'm kind of a newbie) thanks

wind drift
#

Hm I finally got a Prefix working for my barcode scanner

#

but suffix still no luck

#

weird

north stream
#

Weird indeed.

#

I wonder if it's in mode 2C1004 (prefix+data) instead of mode 2C1001 (data + suffix 1)

wind drift
#

Okay I now tested all of those codes

#

apparently prefix+suffix1+suffix2 is working

#

prefix works

#

but all the other ones not

north stream
#

That's annoying, but you can just use prefix+suffix1+suffix2 (or go back to "time since last data sent")

wind drift
#

Yeah I will go for the prefix+suffi1+suffix2

#

And something I am a bit confused about is apparently it can scan "qr codes"

#

But I wonder how? Since the light is a horizontal beam

#

and QR codes are square shaped

north stream
#

Most of the 2D scanners are imaging scanners. The light you see isn't really used by the scanner, it's just an aiming aid so you know it's aligned on the barcode.

rough torrent
#

In Arcada, will setVolume() be implemented?

surreal pawn
#

how are you playing sounds now?

knotty rover
#

I'm using Adafruit_VL53L0X to access it

#

using a feather m0 arduino

surreal pawn
#

does your object move out of view in 33ms?

knotty rover
#

@surreal pawn potentially

surreal pawn
#

I think you'll be better off building a chronograph which has a pair of infrared sensors a measured distance apart and measures the time it takes from the first sensor to change to when the second sensor changes

pine bramble
#

@knotty rover In general, oversampling is the answer.

EDIT: much longer set of musings given in-channel. Deleted, and recopied to a text file (see below).

#

That sensor outputs via i2c so is limited in a way related to i2c bus speed.

#

The (brief!) sample code given shows how to sacrifice the one for the other.

#

I would paint the target object with an emissive and use that object as an obstruction to a sensor on the other side of it, which detects a broken beam.

#

sense when a fast moving object moves

#

20 ms = 0.02 seconds

knotty rover
#

Thanks, I'll do some more tests and check back in

pine bramble
#

I would think you would need at least two samples to have information, not just a singleton.

pine bramble
pine bramble
#

2.6.2 The typical timing budget for a range is 33ms (init/ranging/housekeeping), see Figure 12,
with the actual range measurement taking 23ms, see Figure 9. The minimum range
measurement period is 8ms.

pine bramble
knotty rover
#

thanks for the feedback. my issue ended up not being sampling rate. I had another error in the related code, and the distance sensor is catching what I was looking for

river osprey
#

super basic question - is there a different/which is better (power consumption wise) having a button wired from an Analog/digital pin, to button, then to ground and setting it to PULLDOWN (is that the right one) or having the button between 3.3v, then the button, then the analog/digital pin and setting it to pullup?

#

i'm running it with a Trinket M0, which, like the arudino boards, have pulldown/pullup resistors

north stream
#

Either way works. I tend to use pullup and grounding switches, as that's the only arrangement some other processors support. Some folks like to use pulldown and a switch to Vdd, so a closed switch is a "1" and an open switch is a "0". From a power consumption standpoint, it matters little, but you can try to arrange it so the switch is open more often than closed if you're trying to save the last nanoamperes of current.

burnt island
#

I think I've seen more datasheets that a lot of microcontrollers can sink(pulldown) more current than they can source but the total amount going through the button shouldn't change. and Pull up or downs shouldn't get you anywhere near the total chip current limits

north stream
#

I do remember that TTL circuits can pull down much more strongly than they can pull up, didn't realize some microcontrollers were like that too. I wonder if it's just tradition (like switching to ground in vehicles because the chassis is grounded and it's easy to do) or N-type transistors are smaller/easier to fabricate.

wind drift
#

How can I check if a string contains a number?

#

0-9

#

Currently have this one if no barcode is found

#

if (code.substring(1) == "BNR") {
Serial.println("No Barcode detected");
}

wind drift
#

Okay found a workaround but now another problem

#

    pinMode(interruptPin, INPUT);

    barCodeSerial.listen();

     if (barCodeSerial.isListening()) {
 
      while(barCodeSerial.available()){

       code += (char)barCodeSerial.read();
      }
    }
  } 

  if (code.startsWith("+BNR") == true) {
    Serial.println("No Barcode detected");
    Serial.println(code);
    code = "";
  }

  else if (code.startsWith("BNR") == false && code.endsWith("*+") == true) {
    Serial.println("Barcode detected");
    Serial.println(code);
    code = "";
  }  ```
#

When it reads a barcode it immediately prints it after I release the button

#

But for the no barcode detected it only prints after I have pressed it a second time

#

Why is that?

north stream
#

Hmm, you set it to "listen" mode and then check if it's in "listen" mode, that seems unnecessary, but probably isn't the problem.

#

I'm also not sure why you set the pin as an input after reading from it (as an input)

wind drift
#

Ah yes forgot to remove that

#

I removed the islistening and pinmode part

#

but still the same problem

#

    barCodeSerial.listen();

      while(barCodeSerial.available()){
        code += (char)barCodeSerial.read();
      }
  } 

  if (code.startsWith("+BNR") == false && code.endsWith("*+") == true) {
    Serial.println("Barcode detected");
    Serial.println(code);
    code = "";
  }  
  else if (code.startsWith("+BNR*+") == true && code.endsWith("*+") == true) {
    Serial.println("No Barcode detected");
    Serial.println(code);
    code = "";
  }  ```
#

Even if I do it like this

north stream
#

Probably down to the behavior of the barcode reader, there's probably a delay before it says there's no barcode.

#

May need to move the .available() loop outside the digitalRead() test so it keeps trying it (in which case you probably want to wrap that in the .isListening() test again)

wind drift
#

Ah yes moving it outside the loop kinda helped

#

Okay seems to work so far

#
    barCodeSerial.listen();
  } 

  while(barCodeSerial.available()){
    code += (char)barCodeSerial.read();
  }

  if (code.startsWith("+BNR*+") == false && code.endsWith("*+") == true) {
    Serial.println("Barcode detected");
    Serial.println(code);
    code = "";
  }  
  else if (code.startsWith("+BNR*+") == true) {
    Serial.println("No Barcode detected");
    Serial.println(code);
    code = "";
  }  ```
#

Thanks!

#

onto finding my next problem

errant geode
#

Does someone know why i have this error: Timed out waiting for packet header. when i try to upload code to my esp? This error appear when i solder some things to my esp, here is my wirings:

#

I can hear that speaker buzzes when i try to upload code. Or maybe this is one of modules, like gps modeule? I am not sure.

burnt island
#

it's probably the GPS. uploading code happens over the uart (rxd/txd) so actually using those pins will confuse it.

#

Especially a uart GPS module, which is going to be chattering GPS data in the middle of what should be your program. You'll probably need some sort of connector so you can easily disconnect the GPS when programming

pure coyote
#

tldr; how do I wipe the memory (spi flash?) on a Feather M0.
I'm using a Adafruit Feather M0 WiFi with ATWINC1500 and the Wifi101 library. I've used the provisioning example to connect to it as an AP and then enter my SSID/pwd. That's all working fine but I'd like to be able to clear the SSID/pwd from the device so I can test more easily. I tried to use the Adafruit SPI Flash Total Erase but get the error "Error, failed to initialize flash chip!". Am I on the right path or should I be trying something else? Thanks!

errant geode
#

@Luminescentsimian, I solder switch between 3.3v pin and all of my modules - now it is uploading, so i hope this was a problem, becouse i dont want to unsolder everything. It is working for now, so thank you for your help.

lilac mountain
#

i'm testing out my speaker by looping over the following lines

#
  omega.speaker(NOTE_C4, 100);
  delay(100);
  omega.speaker(NOTE_E4, 100);
  delay(100);
  omega.speaker(NOTE_G4, 100);
  delay(100);
  omega.speaker(NOTE_C5, 250);
  delay(1200);```
#

the NOTE values are defined in the header file, and omega.speaker() is just defined like this

#
void Omega::speaker(int freq, int ms) {
  tone(11, freq, ms);
}```
#

however what i can't figure out is why the last two notes in the sequence tend to falter and output unexpected tones about 50% of the time

#

any ideas?

north stream
#

I don't see how it could be other code interfering with the Arduino, so I'm wondering if there's a mechanical resonance that's making a connection intermittent at those particular frequencies, or perhaps some sort of electrical kickback.

lilac mountain
#

no idea

#

but apparently if i call delay(ms) right after tone() in Omega::speaker(), instead of right after each speaker() call, the problem totally goes away o.o

#

i'll probably have to use millis() just so the program doesn't fully stop

#

@north stream

north stream
#

Hmm, could be some sort of weird timer conflict if delay() and tone() use the same timer? Just guessing at this point.

pulsar steeple
#

Howdy guys, quick question. What is the easiest way to have Adafruit Feather 32u4 Bluefruit LE play audio files through a speaker? Would like to have a way to play certain files from the Adafruit app.

rocky igloo
pine bramble
#

@pure coyote
http://adafru.it/3010

ATSAMD21 + ATWINC1500
The wifi chip is an SPI peripheral; this is an ordinary SAMD21 (G18A) target board with a WiFi peripheral soldered onto it

#

@pure coyote I'm guessing the WINC1500 may have a small storage area in it, so to erase that you'd be talking over the SPI bus, from the SAMD21 chip (SAMD doin the talkin)

#

So you wanna learn the API that talks the language the WINCE chip understands.

#

https://learn.adafruit.com/assets/32983
Reading the schematic it became obvious what the attached storage was (no storage peripheral chip on this target board) and what the protocol was (SPI) to talk to the WINCE chip.

pure coyote
#

@pine bramble thank you. That makes a lot of sense and I didn’t think to explore that avenue. I appreciate the context too. I’ll check it out later this week.

pine bramble
#

(The market may have a target board with external SPI flashROM. Not sure it makes sense to think of the WINCE chip as having an 'internal' spi flashROM.)

#

Could very well be that while the Adafruit vended target has no external spi flashROM, some other vendor's work does. I don't know. ;)

#

Good place to dig for background. ;)

#

and I'm back quiet.

potent ferry
#

I am still here and I am still looking for help please.

How can I sue the ADXL345 with my code ?

This is my code

https://justpaste.it/2kr6k

Can someone please tell me the lines of code needed to use the 2 new ADXL345 accelerometers , in place of the 2 old GY6050 ?

Thanks

proven mauve
#

hey, please excuse this question sounding kinds dumb... but if I have an atmega running an i2c screen and it's already borderline starting to run a little slower than I'd like.... if I add a second screen and give it display instructions as well it will significantly slow down the program as well, yeah? Using ssd1306 and sh1106 screens with the adafruit library, and addon for the sh, and adafruit_gfx if that matters...

north stream
#

You should be able to use SH1106 one with SPI, which is much faster and can use hardware acceleration

proven mauve
#

I didn't realize sh1106 came in spi too, I'll have to look into that, I have tons of pins. The extra physical size of the 1106's is nice

#

at least, the onses I've been messing with. I think I've got 1.3" instead of the .96" and they fit well... they're just slower than my ssh1306 spi stuff

fresh pendant
#

I have made some modifications to Adafruit_MP3, which is an Arduino library. Can someone point me at a guide for how to build locally with my version of this library?

proven mauve
#

You just make sure your files are the one in /documents/adruino/libraries/thelibrary

fresh pendant
#

will this location risk being overwritten if the official Adafruit_MP3 library gets an update?

proven mauve
#

yes, but I think as you don't manually update it in the ide you should be okay... I think

#

I would keep a backup just in case

fresh pendant
#

okay, by habit I keep all my git clones under ~/src so I can just copy it into place as needed I guess

#

thanks, I'll give this a whirl!

north stream
#

You can also include the files in your build directory but you might want to rename it in either case to avoid conflicts with the existing library

#

You can make a softlink from arduino/libraries to your git clone (I do this a lot)

proven mauve
#

avrdude may pick the wrong one when compiling if you don't rename it from what I understand, ya?

fresh pendant
#

I suppose if I don't install it from the library manager then it won't update via library manager either? I don't know much about how this works.

north stream
#

You may also get "multiple libraries found" complaints (I get those a lot too)

proven mauve
#

jepler, I think you're correct. If it's not installed in the ide it wont try to update it

#

I'm not sure if the ide has auto updates off the top of my head tho... I know i have to use old i2c libraries to run screens faster and it doesn't ever override them once i pick a version

proven mauve
#

one of my $10 1284 chips seems to be burned out 😦 Keeps returning a serial of 0x000000

north stream
#

Are sure it's set up properly?

pine bramble
#

can someone help me use an IL9341 featherwing TFT to post cereal data from projects?

pine bramble
#

Well hello! I am trying to create a pressure sensor using pressure sensitive clothe and velostat. I've got code made that basically shows the difference from analog port 0 to ground (positive negative) but I'm such an amateur, heh. I just took the pins and poked them through the cloth, and I'm not using a resistor at all in this, but I don't know if that is necessary or not in this case. I would like to know what kind of resistor would be necessary for that if one would (it's arduino uno so 5v to ground currently). If anyone just likes speaking arduino or has a great guide for it that they like, I'd appreciate any information.

north stream
#

You probably do need a resistor (to the positive voltage supply), so you basically have a tug-of-war between the resistor pulling up and your sensor pulling down. Then the Arduino can measure the voltage between them and calculate how hard the sensor is pulling down.

#

The value of the resistor depends on the resistance of your sensor, but 10k is often a workable starting value.

simple horizon
#

Any idea as to why I'm getting like 3633 PPM using the MQ135?

#

I'm using an esp32 feather

#

oh... uh it literally reads the same thing when I take the sensor off.

north kelp
#

@simple horizon How's it connected to the esp32?

simple horizon
#

VCC to 5V, GNG to GND, AO to A0

#

It's working better now that I set analog read to A0 instead of 0 but it's 1653 PPM now

north kelp
#

Is WiFi on?

simple horizon
#

no

north kelp
#

I'd try A1 and change the code accordingly.

simple horizon
#

But it's not on ADC #1. I thought was literally just two pins

#

But I'll change it.

north kelp
#

A0 is on ADC #2. A1 is on ADC #1.

simple horizon
#

I'm not trying to argue but it the pinouts say this
"A1 - this is an analog input A1 and also an analog output DAC1. It can also be used as a GPIO #25. It uses ADC #2"

north kelp
#

Oh drat. My bad.

simple horizon
#

So try A2?

north kelp
#

Yep. That's what I'd do.

simple horizon
#

When I put the pin into AnalogRead() do I use A2 or the GPIO pin of 34?

north kelp
#

I'd try A2 first.

simple horizon
#

Ok, that's what I have now

#

Now it's around 1297

north kelp
simple horizon
#

I think it might have to be a decimal issue? It don't know.

#

When I unplug it goes to 0 as it should.

#

This is my print statement "Serial.print(sensorValue, DEC)"

north kelp
#

Yep. Does it change with a bit of smoke blown on it?

#

Or just breathing on it?

simple horizon
#

Yes it does

north kelp
#

Yay! Progress.

#

There will probably be some scaling of the output numbers, since you're using ESP32 vs UNO. They have different analog reference voltages.

simple horizon
#

ya and I think he kinda takes care of that via mapping

north kelp
#

He's using an UNO, which has 0-5V analog input. Your ESP32 analog inputs range from 0 to 3.3V, I believe.

#

So your numbers may be 1.52x higher. (I think)

simple horizon
#

still seems too high for it to be 1.52x higher

north kelp
simple horizon
#

but I'll follow this tutorial

north kelp
#

I'd use caution with a 3.3V system, and disconnect from ESP32's analog input for now.

#

You may need a voltage divider (resistors) to scale down the output voltage on the sensor's A0 pin.

simple horizon
#

should I just go back to the arduino?

north kelp
#

If there's a possibility of generating more than 3.3V from the sensor's A0 pin could damage the ESP32.

simple horizon
#

would a MKR VIDOR 4000 be sufficient?

#

jk I found my uno

#

lol

#

So now it says 255 ppm

#

Goes up to like 332 ppm when I blow on it

#

So about 4.4x higher on the esp32

north stream
#

Your code would have to account for differences in supply voltage, pull-up resistance, and digitizer reference voltage.

simple horizon
#

I think I'm just going to use the uno for now because this is just to get the values with little regard to value accuracy. I'm using it for processing

charred salmon
#

Quick question about DotStars. I'm in the early planning stage of a project that will involve multiple channels of DotStar strips. Is it possible to have all the strips share the same clock line? Just thinking of reducing pin counts.

#

I'm looking at the datasheet, and it looks like it should work? Start frame is defined as 32 0s down the line, and each LED starts with three 1s before the actual meaningful data.
I just don't know if after seeing the 32 0s, it just keeps waiting for valid data, considering every new 0 to be the "32nd 0" in the sequence.

north stream
#

Should be possible to share a clock, but many hardware SPI implementations only support one MOSI line. You may also need a buffer if you don't have enough fanout on a GPIO pin, and series resistors if reflections cause issues.

#

As for the zeros, I figure it's at least 32, and more won't change anything further.

charred salmon
#

Well, I'm going with DotStars in part because they specifically can be used on any two pins, hardware backed SPI or not. I hadn't thought about signal reflections, but I don't think they'll be an issue since everything will be terminated.
I don't know what you mean by needing a buffer for not having enough fanout. Is this just regarding the signal being strong enough for each strip?

#

Really this question is part of a "what if" scenario. I'm driving the lot with a Feather, so if I do nothing else, I can get 10 channels without sharing clocks. 9 if I want to monitor the battery pack (which I do). 9 channels is most likely plenty, but I like considering my options.

north stream
#

Yeah, just make sure the Feather has sufficient current drive capability to drive all that capacitance and all those inputs. Depending on your power supply layout, you may want level shifters, which would generally provide the buffering for you as well.

charred salmon
#

Oh there'll definitely be a level shifter in there.

#

I know for small things you can run DotStars off 3.3 with 3.3 logic, but I'll have them on 5v, so gonna get 5v logic to them as well.

vague kettle
#

off topic, and this part of the project is a c++ pi program, but i still wanna show it off

#

next step, send that data to the arduino to display, and move the motors

#

🙂

#

already got serial comms working between the 2, and spent a few hrs tonight text formatting so the numbers would show how i want, in 2x16 chunks 🙂

proven mauve
#

So... I've got two atmega1284s that started returning a signature of 0x000000 under different circumstances. The second one I have breadboarded with an external 16MHz crystal and have been flashing programs to it today without changing the breadboard at all except that one of the last programs I flashed to it I had it connected to 3.3v instead of 5v. Now I can't flash anything, hooked up to the ICSP pins, because of the signature.... Any ideas if this is recoverable?
I would really like to keep using these $10 chips.... expensive to brick 😦
.... I also don't get why this last one bricked if the only difference was the 3.3v, I've been making minor corrections to a program and reflashing

proven mauve
#

For reference, I've tried using an external power supply and tried swapping the oscillator crystal for a couple other ones just in case

#

I've also checked the resistance between VCC and GND and it's very high, in the M range

acoustic nebula
#

have you tried switching the fuse bits to use the internal oscillator too?

north stream
#

@proven mauve It's possible some bits got programmed to weird states: the usual way to rescue those is with a "high voltage" programmer that can reset chips that have gotten confused and don't respond to normal programmers. I normally use an STK500 for this, but there are other options out there.

proven mauve
#

@north stream @acoustic nebula So I did try to flash the fuse bits with avrdude back to the internal oscillator, owever it wasn't changing the bits, even with -F

#

madblogger, I have some unos and nanos laying around, and some pro micros too, as well as an adjustable power source, would any of that work as a high voltage programmer?

north stream
#

I'm on phone at the moment but try searching for "DIY high voltage AVR programmer "

proven mauve
#

will do, thanks for the tip!

north stream
#

You should check the chip data sheet and see if it supports serial or parallel high voltage programming - serial is generally easier if it's supported

proven mauve
#

kk

proven mauve
#

So the only mention is "The RESET pin accepts 5V active low logic for standard reset operation, and 12V active high logic for High Voltage Parallel programming. "

#

okay, I see.... and I see why parallel is a pita

#

It LOOKS like I can do this with an UNO, a 12v supply, a few 1k resistors, and a transistor.....

proven mauve
#

@north stream are you around?

north stream
#

I'm back now (was taking the cat to the vet)

proven mauve
#

I hope he's good to go!

#

I got to the very last steps of scratch monkey, and of course it's old enough to be incompatible with the IDE now

#

so after everything was wired and right before I hit burn bootloader I ran into problems getting it to list as a programmer, then when I got it to list it wouldn't run

#

So I swapped to the simple hvpp sketch, which runs over serial

#

I can get the initial menu up but it wont communicate after that 😄

#

So... what sketch and programmer settings do you use to HVPP?

#

I've got to get some sleep, but I will definitely follow up tomorrow to try and get these chips running again. I think this really may fix it

#

THanks again for the help!

mild elk
#

I'd like to build a simple device that can access 28c64 or 28c256 EEPROM and for example dump it or write a .bin file to it. I thought about using an SD card reader, but I think it would be inconvinient to have to remove the card and put it into my computer to see the dump or to copy the file I want to write. Is it possible to send/receieve files over serial connection?

north stream
#

I don't think an SD card reader would help. You can write a simple sketch to read off the data with an Arduino and send it back over a serial link.

#

I'm actually toying with the notion of creating a custom shield to read EEPROMs and write FRAM and the like.

mild elk
#

So it probably comes down to writing a program on my computer that either reads incoming serial data and puts it into a bin file or reads a bin file and sends it byte-by-byte over serial. Does that make sense?

north stream
#

Yeah. What I'd probably do is have the Arduino send the data in hexadecimal, then have a program that either saves it verbatim (and use an ordinary .hex to .bin converter afterward) or translates the hex into binary and saves that on the fly.

pine bramble
#

I'm away from my computer just handheld

elder hare
#

on arduino.cc they say that you can power an arduino with 9 to 12V adapter... can i power it with 5V 3A adapter?

pine bramble
#

@elder hare I don't know offhand, but usually you need a little headroom above the chip's supply voltage.
Which target board?

elder hare
#

Arduino Mega 2560

pine bramble
#

What is the GPIO voltage range on that one? (It's not quite a new design iirc)

#

6.5 volts

#

Looks like you could feed 5VDC to Pin 1 of the 36 pin header (18x2). Not sure on that.

#

Also Pins 2 and 5 on one of the 8-pin headers

#

Those locations seem to feed Pin 2 and Pin 4 of the NCP1117, which is where 5V comes out of it.

#

So you cannot use the traditional means of powering that one with a 5VDC supply, but you may get away with feeding it 5VDC at those pins mentioned (but don't use the traditional connector at all, then).

#

The traditional connector might be okay if fed 6.2 volts, but 6.5 volts seems to spec.

#

A 9V supply gives a lot more headroom, which may be why it is recommended.

north stream
#

I'd probably just run the 5V supply into the USB input

pine bramble
#

That doesn't seem to work. ;)

#

ATMEGA16U2 has 'USBVCC' which is distinct.

#

It also has VCC which may be supplied through the ATMEGA16U, sourced from USBVCC (I don't know).

#

Is that the idea here?

#

Fig 2.1 of ATMEGA16U2 datasheet shows an internal 3.3v regulator fed by USBVCC.

north stream
#

Weird, as it should be able to be powered by USB

pine bramble
#

Yeah I don't get it (at all). ;)

#

But there doesn't seem to be a supply path from USBVCC to VCC 5V.

#

(there could be internal to the ATMEGA16U2 .. dunno)

#

Sounds like you're correct (anyway) @north stream by the sales pitch from Arduino for this target. ;)

north stream
#

Usbvcc might be something other than the USB supple

#

*supply

pine bramble
#

The schematic seems to say that's the one used from the USB connector.

#

@elder hare You should be able to feed 5VDC from your adaptor to the USB jack on the Arduino, no problem. ;)

pine bramble
#

I have the answer. ;)

#

I was a redshirt on Star Trek, too ;)

proven mauve
#

@north stream @pine bramble hey happy thanksgiving!

#

I am giving thanks for you guys helping me a lot the past few weeks 😄

proven mauve
#

@north stream do you have a suggestion for a sketch to run a HVPP? I've got everything to make the setup, I just can't find a good way to actually do it. I'm running in to a lot of dead ends with the age of things compared to the IDE version and it doesn't help that I'm reprogramming 1284's

north stream
#

I found a couple of projects out there with sketches, but they'd probably have to be adjusted for your case. Unfortunately, I haven't done it that way (I have an ancient STK500 I use for the purpose) so I don't know a lot of the ins and outs.

proven mauve
#

Aha, I see. Well thanks or getting me on this path, I'm sure it's whats wrong

proven mauve
#

madbodger, what do you use to make your stk500 do HVPP flashing?

#

oh... nevermind... those things run off of serial ports haha

north stream
#

Heh, I use avrdude 🙂

proven mauve
#

@north stream madbodger after many attempts, applying about 10 fixes to the stuff because it's outdated, and feeding it into avrdude manually... I got my HVPP setup working and unbricked the chips. The problem was absolutely the fuses. I really appreciate you suggesting that

wind drift
#

'2 53 54 48 48 50 52 57 51 66 50 83 3 '

#

is a code it's reading

#

02 is head; 03 is End number

#

how do I get the 0 in front of there?

north stream
#

@wind drift Are you getting the code as bytes or a string or what? You can do two approaches for leading zeros. One is to simply do the check explicitly: ```c
if (value < 10) {
Serial.print('0');
}
Serial.println(value);

#

Another approach is to use a print formatter: ```c
char buffer[20];

sprintf(buffer, "%02d", value);

Serial.println(buffer);

#

@proven mauve Good job working that all out and getting them fixed! Are you going to post your updated code somewhere so someone else in the same situation can use it?

proven mauve
#

Honestly, I'm reluctant to, it's a pretty hacky job. Had to add an avr folder and empty boards txt to the hardware to get the programmer board to show up in menu, then had to uncomment debug mode and also had to add my chip name into another part of the configurations, and I think that got me far enough that it compiled, then I had to try and flash the bootloader and copy the avr command it kept erroring on and paste it into cmd and edit a bunch of things in it, like adding the com port, deleting a variable that displayed as text instead of an actual value, then added in my flash values instead of the crazy ones it wanted to default, and make it only flash one at a time instead of trying all 3 at once...

wind drift
#

@north stream I was just printing them one by one as an int

north stream
#

In that case, either approach I mentioned should work for you.

wind drift
#

int r = Rfid.read();

Serial.print(r);

#

Okay I will give it a try

#

seems to work

#

thanks!

proven mauve
#

If someone ends up interested in updating scratch monkey to work with the newer IDE I would be happy to help, but my knowledge has too many gaps to actually do a clean job of it at the moment

pine bramble
#

I publish ugly code with expired-context comments, as if that were the planned outcome.

potent helm
#

so I have been playing with building my own keybard, and with the discount today I thoucght why not get a feather

#

has anyone done that recently, I have read in the past of a feather being used

vague kettle
#

my brain is fried. can i get somebody to look at 12 lines of C, and gimme a hand?

#

i have a stepper motor with 600 steps (i used a 3:1 gear ratio). just trying to work out how to move the shortest distance to my destination

#

currPos = 595; nextPos = 5. the result should be +10 steps

#

math is hard

rocky igloo
#

@vague kettle Looks like you need to check for four different conditions:

#
  1. nextPos - currPos > 300: go backward through zero to get to nextPos
#
  1. nextPos - currPos > 0 but <= 300: go forward by nextPos - currPos steps
#
  1. nextPos - currPos < 0 but > -300: go backward by currPos - nextPos steps
#
  1. nextPos - currPos <= -300: go forward by nextPos - currPos + 600 steps
#

(Doing math in my head... I think in case 1, you go backward by currPos - nextPos + 600 steps, but definitely check me on that.)

vague kettle
#

that code works in some cases, but currPos=595; nextPos=5; breaks it. result is -590

#

*the code i posted that is. im working on the stuff you posted

rocky igloo
#

Right, it's less than -300. In my code you'd go forward by 5 - 595 + 600 = 5 + 5 = 10 steps.

#

Alternatively you could use the modulo operator: delta = (nextPos - currPos) % 600 and then go backward by 600 - delta if delta > 300. It's shorter but maybe also less clear.

vague kettle
#

thats the way i like it. this seems to work

#

looks like it works with anything i throw at it... i think?

#

i think it works. any edge cases i should think of?

#

5,10 works. 10,5 works. 595, 5 works. 5, 595 works. 0, 299. 299,0. 301,0. 0,301.

#

i think it works

rocky igloo
#

Should be good to go.

vague kettle
#

im going with it

vague kettle
#

azimuth from my home, is 60. it says to move 60 steps. so far so good lol

#

and im doing that math manually, not checking this website from my code. just using it to confirm my results

#

60 steps is incorrect, but at least i see the problem, and im getting close

grand skiff
#

if I connect both arduinos to the PC the same time in this setup would it fry them

dense kiln
#

What kind of protection do I need to power an Arduino and motor shield with a 3s lipo (11.1v)?

north stream
#

@grand skiff That should be fine

#

@dense kiln You can power them both with that supply simply and safely enough. You can connect the supply to either the shield's motor input, or the barrel jack on the Arduino Then install the VIN jumper on the shield to connect the motor supply to Vin, to connect Vin and the motor supply together. This is a popular configuration, which is why the jumper is provided to allow using a shared supply like this. It's described here: https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/powering-motors#if-you-would-like-to-have-a-single-dc-power-supply-for-the-arduino-and-motors-7-4

dense kiln
#

The motor shield info warns to disconnect the Vin connect jumper in case the supply is over 9V. So I thought about wiring the battery to the barrel jack and to the power pins on the shield. Is this good?

#

I also thought about getting a voltage booster for 12V, so it never goes below 12V even when the battery discharges. Is this safe? Sorry for bothering you even more

north stream
#

The way I read it, an ordinary 9V battery is insufficient to run it, but 6-12V supplies capable of sufficient current should be fine.

#

More than 12V would be too much for both the regulator on the Arduino and the motor controller chips on the shield.

#

If I have a choice, I normally prefer to wire the power supply to the shield instead of the Arduino. My thinking is that the shield is the high-current load, so it should have the best connection to power.

dense kiln
#

Or would it be safer to just forget this weird plan and power the Arduino with a 9V common battery and the motors with the Lipo?

north stream
#

It's probably safer, if not simpler.

dense kiln
#

Thanks a lot!

#

Is the booster a good idea for the lipo and motors though?

north stream
#

Generally not: 11.1V is pretty near the maximum as it is, so unless you need the very last bit of torque/speed and don't mind losing battery life, I'd stick with that.

dense kiln
#

Guess I won't be using one then. Thank you so much!

proven mauve
#

@pine bramble just got back here, I lol'd

stuck glade
#

I have the 3.5” TFT breakout connected to the feather M0. Whenever there is a fluctuation in power the screen turns gray and only rebooting the arduino fixes it.

Any ideas how to get the display to show stuff again without restarting the M0? Thanks!

grand skiff
#

@north stream thanks!

wet crystal
#

Could the ESP8266 start a phone call in my network?

#

And play short audio?

potent ferry
#

Is there anyone that could please help me adding the lines to inizialize and use the adafruit adxl345 acceleromer in my code?

#include <GY6050.h>
#include <Wire.h>
#include <VarSpeedServo.h>

#define angle1 20
#define angle2 90

#define Sensor_BL A0
#define Sensor_BR A1

VarSpeedServo servo1;


GY6050 gyro1(0x68);
GY6050 gyro2(0x69);

int X = 0;
int Y = 0;

int y1_axis = 0;
int y2_axis = 0;

int sensorBL;
int sensorBR;

int speed = 0;
int angle = 0;

int prev_y1_axis = 0;
int y1_hold = 0;
unsigned long timer;
int start=1;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  gyro1.initialisation();
  gyro2.initialisation();
  delay(100);
  servo1.attach(8);
  servo1.write(90);
}

void loop() {
  y1_axis = gyro1.refresh('A', 'Y');
  y2_axis = gyro2.refresh('A', 'Y');
  sensorBL = analogRead(Sensor_BL);
  sensorBR = analogRead(Sensor_BR);
pine bramble
#

```cpp
int main(void) {
statement();
}
```

wet crystal
#

Thx

#

I always get it wrong the first time 😄

potent ferry
#

I had no clue how to add th code properly

#

thanks

pine bramble
#

;)

wet crystal
#

This is also usefull